Example usage for java.lang String replaceAll

List of usage examples for java.lang String replaceAll

Introduction

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

Prototype

public String replaceAll(String regex, String replacement) 

Source Link

Document

Replaces each substring of this string that matches the given regular expression with the given replacement.

Usage

From source file:alpine.util.UuidUtil.java

/**
 * Removes hyphens from a 36 character UUID.
 * @param uuid the UUID to strip hyphens from
 * @return a String of the UUID without hyphens
 * @since 1.0.0// w w w  .  j av a  2s . c om
 */
public static String stripHyphens(String uuid) {
    return uuid.replaceAll("-", "");
}

From source file:de.shadowhunt.subversion.internal.ResourcePropertyUtils.java

static String filterMarker(final String xml) {
    return xml.replaceAll(MARKER, COLON);
}

From source file:edu.ucla.cs.scai.linkedspending.index.Utils.java

public static String normalizeWords(String w) {
    w = w.replaceAll("[^A-Za-z0-9']", " ");
    //separate camel case words
    if (!w.contains(" ")) {
        w = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(w), ' ');
    }/*from  w ww.  j  a  v a  2 s.  c o m*/
    //collapse multiple spaces
    w = w.replaceAll("\\s+", " ");
    //change to lower case
    w = w.toLowerCase();
    return w;
}

From source file:com.codenjoy.dojo.utils.UnicodeUtils.java

public static String unescapeJava(String data) {
    return StringEscapeUtils.unescapeJava(data.replaceAll("\\\\u", "\\u"));
}

From source file:Main.java

public static List<String> getSortedStringList(Collection<String> toSort) {
    List<String> sorted = new LinkedList<String>();
    final PriorityQueue<String> ordered = new PriorityQueue<String>(
            toSort.size() + 1/*In case the toSort is empty*/, new Comparator<String>() {
                @Override//from  w  w  w. j  av a 2 s. co  m
                public int compare(String lhs, String rhs) {
                    lhs = lhs.replaceAll("[^a-zA-Z0-9]", "");
                    rhs = rhs.replaceAll("[^a-zA-Z0-9]", "");
                    int result = rhs.compareTo(lhs);
                    return result;
                }
            });
    ordered.addAll(toSort);
    int originalSize = ordered.size();
    for (int i = 0; i < originalSize; i++) {
        sorted.add(ordered.poll());
    }
    return sorted;
}

From source file:Main.java

public static boolean isDocumentUrlValid(String str) {
    try {/*from   w  ww .  j ava 2  s  .  com*/
        URL url = new URL(str.replaceAll(" ", "%20"));
        url.toURI();
        return true;
    } catch (MalformedURLException e) {
        return false;
    } catch (URISyntaxException e) {
        return false;
    }
}

From source file:cloudfoundry.norouter.f5.Json.java

public static String escape(String json) {
    return json.replaceAll("\"", "`");
}

From source file:com.yifanlu.PSXperiaTool.StringReplacement.java

public static String filter(String value) {
    return value.replaceAll("\\'", "\\\\\\\\'").replaceAll("\\\"", "\\\\\\\\\"");
}

From source file:Main.java

public static Set<Integer> getNumsFromStr(String text) {
    text = null == text ? "" : text;
    String[] ary = text.replaceAll("[^\\d]", " ").split("\\s+");
    Set<Integer> set = new TreeSet<Integer>();
    for (String num : ary) {
        if (!num.trim().equals("")) {
            set.add(Integer.valueOf(num.trim()));
        }//from   www .j  a va2 s  .c  om
    }
    return set;
}

From source file:Main.java

public static final String replaceKeyString(String key) {
    if (key == null)
        return "null";

    key = key.replaceAll("\r\n", "<femtobr>");
    key = key.replaceAll("\r", "<femtobr>");
    key = key.replaceAll("\n", "<femtobr>");
    key = key.replaceAll("\t", "<femtotab>");
    return key;/*from  w  w  w  . j a  v  a  2 s .co m*/
}