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:com.threewks.thundr.googleapis.prediction.PredictionDataHelper.java

public static String remove(String string, String regex) {
    return string == null ? "" : string.replaceAll(regex, "");
}

From source file:Main.java

public static String replaceCharacters(String in, String[][] replacement) {
    if (in == null || ("".equals(in)))
        return "";
    String retVal = in;
    for (int j = 0; j < replacement.length; j++) {
        retVal = retVal.replaceAll(replacement[j][0], replacement[j][1]);
    }//  w  w  w .  j  a  va2  s  .  c  o  m
    return retVal;
}

From source file:Main.java

/**
 * removes Special Signs from primKey to create a table with primKey in name.
 *
 * @param primKey primKey//from w w w.  j  a v a 2s .  c  o m
 * @return String primKeyWithoutSpecialSigns
 */
public static String convertPrimKeyToTableName(final String primKey) {
    if (primKey != null) {
        return primKey.replaceAll("\\:", "");
    }
    return null;
}

From source file:org.apache.aries.blueprint.plugin.model.Property.java

/**
 * Remove default value definition//  w  ww  . j a  va2  s . c  o  m
 * 
 * @param value
 * @return
 */
private static String cleanValue(String value) {
    return value.replaceAll("\\:.*\\}", "}");
}

From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.matchingstrategy.MatchingSmallLevenshtein.java

/**
 * The normalized form of the string is lowercase and contains no punctuation,
 * no trailing and no successive whitespace.
 * <p>/*w ww  . j  a  v  a 2s. c  om*/
 * The normalization is a bit rough, f.e. "Henry's son" becomes "henrys son".
 *
 * @param string
 *          to be normalized
 * @return
 */
private static String normalizeString(String string) {

    string = string.replaceAll("[.!?'\"/]", "");
    string = string.replaceAll("[\\n\\r\\t\\f-/_]", " ");
    string = string.replaceAll(" {2,}", " ");
    string = string.trim();
    return string.toLowerCase();
}

From source file:Main.java

public static Document toDocument(String s) throws Exception {
    s = s.replaceAll("&", "&amp;");
    return toDocument(new ByteArrayInputStream(s.getBytes()));
}

From source file:Main.java

public static String filterBOMJsonStr(String jsonStr) {
    if (jsonStr != null && jsonStr.startsWith("\ufeff")) {
        jsonStr = jsonStr.replaceAll("\ufeff", "");
    }//w  w  w  .  ja  va 2s .  c  o m
    return jsonStr;
}

From source file:com.alifi.jgenerator.utils.StringFormatUtils.java

/**
 * /*from  w w  w .  java2 s . c  o m*/
 * 
 * @param str
 * @return
 */
@SuppressWarnings("deprecation")
public static String hump(String str) {
    if (StringUtils.isNotEmpty(str)) {
        String s = str.replaceAll("_", " ");
        s = StringUtils.capitaliseAllWords(str);
        return s.replaceAll(" ", "");
    }
    return null;
}

From source file:com.mobius.software.mqtt.performance.commons.util.IdentifierParser.java

public static String parseIdentifier(String regex, String username, String server, Integer identifier) {
    StringBuilder sb = new StringBuilder();
    List<String> segments = Arrays.asList(regex.split(REGEX_SEPARATOR));
    for (String segment : segments) {
        segment.replaceAll(REGEX_SEPARATOR, "");
        if (segment.equals(Template.IDENTITY.getTemplate()))
            sb.append(identifier).append(IDENTIFIER_SEPARATOR);
        else if (segment.equals(Template.ACCOUNT.getTemplate()))
            sb.append(username).append(IDENTIFIER_SEPARATOR);
        else if (segment.equals(Template.SERVER.getTemplate()))
            sb.append(server).append(IDENTIFIER_SEPARATOR);
        else if (!segment.isEmpty())
            throw new IllegalArgumentException("invalid regex expression");
    }//  www.ja  v a2s.c om
    String result = sb.toString();
    return result.substring(0, result.length() - 1);
}

From source file:Main.java

/**
 * a Chinese character takes up two-char-space but only counts one char, this method 
 * replace the Chinese Character with "aa"(just arbitrary chosen here),with dealing with 
 * operations like String.subString(int beginIdx,int endIdx);
 * @param s/*from  w ww . ja v a2  s .  co m*/
 * @return a String with all the Chinese Character in it replaced by "aa"
 */
public static String replaceChineseChar(String s) {
    String regEx = "[\u4e00-\u9fa5]";
    String tem = s.replaceAll(regEx, "aa");
    return tem;
}