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:Main.java

public static String handleInputSpace(String s) {
    if (s != null) {
        s = s.replaceAll("\r", "");
        s = s.replaceAll("\n", "");
        s.trim();/*  w ww .jav  a 2s  .c  o  m*/
    }

    return s;
}

From source file:keywhiz.auth.User.java

public static boolean isSanitizedUsername(String name) {
    return name.equals(name.replaceAll(USERNAME_PATTERN, ""));
}

From source file:com.bluexml.side.util.libs.StringHelper.java

/**
 * take a string like "word<token>word2<token>word3"
 * //from   www .  j av  a2s.  com
 * @param st
 * @return "wordWord2Word3"
 */
public static String getJavaQName(String st, String token) {
    String token_ = token.replaceAll("\\\\", "");
    String first = st.substring(0, st.indexOf(token_));
    String other = st.substring(st.indexOf(token_));
    String intermediate = other.replaceAll(token, " ");
    String out = WordUtils.capitalize(intermediate);
    return first + out.replaceAll(" ", "");

}

From source file:Main.java

public static int PecentToInt(String percentValue) {
    percentValue = percentValue.replaceAll("%", "");
    int newValue = 0;

    try {/*from ww w. ja  v a2  s .  c om*/
        double temp = Double.parseDouble(percentValue);
        newValue = Integer.parseInt(new java.text.DecimalFormat("0").format(temp));
    } catch (Exception e) {
    }

    return newValue;
}

From source file:com.redhat.utils.PluginUtils.java

public static String getSubstitutedValue(String id, EnvVars env) {
    String text = id.replaceAll("\\$([a-zA-Z_]+[a-zA-Z0-9_]*)", "\\${$1}"); //replace $VAR instances with ${VAR}.
    StrSubstitutor sub1 = new StrSubstitutor(env);

    return sub1.replace(text).trim();
}

From source file:Main.java

/**
 * Given xml strings containing xml reserved characters, replace with displayable characters > <= & gt; < <= & lt; &
 * <= & amp; ' <= & apos; " <= & quot;
 *///from w  ww  .ja  v a2s.  c o m
public static String xmlToText(String xml) {
    if (xml == null || xml.equals("")) {
        return "";
    }
    String str = xml;
    str = str.replaceAll("&gt;", ">");
    str = str.replaceAll("&lt;", "<");
    str = str.replaceAll("&apos;", "'");
    str = str.replaceAll("&quot;", "\"");
    str = str.replaceAll("&amp;", "&");
    return str;
}

From source file:Main.java

public static boolean launchURLFromXML(String urlFromXML) {
    return launchURL(urlFromXML.replaceAll("&amp;", "&"));
}

From source file:Main.java

public static String colorizeSequence(String cigar, String seq) {
    String[] letter = cigar.replaceAll("[0-9]", "").split("");
    String[] nums = cigar.split("[MIDNSHPX]");
    int index = 0;
    String htmlEmbedded = "";
    for (int i = 0; i < nums.length; i++) {
        int tail = Integer.parseInt(nums[i]) + index;
        if (letter[i + 1].equals("M")) {
            htmlEmbedded += seq.substring(index, tail);
        } else {//from www  . j a  va 2 s.com
            htmlEmbedded += "<span class=\"warn\">" + seq.substring(index, tail) + "</span>";
        }
        index += Integer.parseInt(nums[i]);
    }
    return htmlEmbedded;
}

From source file:org.bin01.db.verifier.Query.java

private static String clean(String sql) {
    sql = sql.replaceAll("\t", "  ");
    sql = sql.replaceAll("\n+", "\n");
    sql = sql.trim();//from   w  w w.j a v a  2s  .  co m
    while (sql.endsWith(";")) {
        sql = sql.substring(0, sql.length() - 1).trim();
    }
    return sql;
}

From source file:com.shazam.fork.utils.ReadableNames.java

private static String capitalize(String name) {
    return capitalizeFully(name.replaceAll("[\\W]|_", " "));
}