Example usage for java.lang String split

List of usage examples for java.lang String split

Introduction

In this page you can find the example usage for java.lang String split.

Prototype

public String[] split(String regex) 

Source Link

Document

Splits this string around matches of the given regular expression.

Usage

From source file:Main.java

public static boolean compareUrl(String ur1, String ur2) {
    String[] s = ur1.split("//");
    String[] s1 = ur2.split("/");
    ur1 = s[s.length - 1];/*from w w w .  j  av a  2s  .c  o  m*/
    ur2 = s1[s1.length - 1];
    return ur1.equalsIgnoreCase(ur2);
}

From source file:Main.java

public static String[] getExtList(String str) {
    return str.split("[\\, ]+");
}

From source file:Main.java

/**
 * Separates the hour segment from a date string and converts and returns it as an int.
 * The hour string must be the last segment, preceded by a colon, eg: dd.MM.yyyy:HH.
 *
 * @param date The string representation of the date.
 * @return The hour segment in int form.
 *///from   ww  w . j a va  2  s  .c  o m
public static int getHourFromDate(String date) {
    return Integer.parseInt(date.split(":")[1]);
}

From source file:Main.java

private static String getSimpleName(final String event) {
    final String[] split = event.split("\\.");
    return split[split.length - 1];
}

From source file:Main.java

public static String getLastString(String str) {
    String[] splitStr = str.split("/");
    int len = splitStr.length;

    if (len == 0)
        return str;

    String result = splitStr[len - 1];
    return result;
}

From source file:Main.java

public static String changeText(String str, long num) {
    String strs[] = str.split(" ");
    return strs[0] + " " + num;
}

From source file:Main.java

public static String stripInnerClass(String className) {
    String[] split = className.split("\\$");
    if (split.length == 0) {
        return className;
    } else {//w  w w  . j a  va  2s . c o m
        return split[0];
    }
}

From source file:Main.java

public static String simpleClassName(String className) {
    String[] split = className.split("\\.");
    if (split.length == 0) {
        return className;
    } else {/* w ww .  java2  s  . c o m*/
        return split[split.length - 1];
    }
}

From source file:Main.java

public static int addToWordSet(Set<String> wordSet, String words) {
    String[] r = words.split(",");
    int count = 0;

    for (String word : r) {
        wordSet.add(word);/*from  w w  w.j  a  v a2 s  . co  m*/
        count++;
    }

    return count;
}

From source file:Main.java

public static String getFuzzyIp(String ip) {
    final String[] ipParts = ip.split("\\.");
    if (ipParts.length == 4) {
        return String.format("%s.%s.*.*", ipParts[0], ipParts[1]);
    }/*from   w w w.jav  a  2s .  c om*/

    return ip;
}