List of usage examples for java.lang String replaceAll
public String replaceAll(String regex, String replacement)
From source file:Main.java
/** * Apply quoting rules per IMAP RFC,//w ww . j a v a 2 s . c o m * quoted = DQUOTE *QUOTED-CHAR DQUOTE * QUOTED-CHAR = <any TEXT-CHAR except quoted-specials> / "\" quoted-specials * quoted-specials = DQUOTE / "\" * * This is used primarily for IMAP login, but might be useful elsewhere. * * NOTE: Not very efficient - you may wish to preflight this, or perhaps it should check * for trouble chars before calling the replace functions. * * @param s The string to be quoted. * @return A copy of the string, having undergone quoting as described above */ public static String imapQuoted(String s) { String result = s.replaceAll("\\\\", "\\\\\\\\"); result = result.replaceAll("\"", "\\\\\""); return "\"" + result + "\""; }
From source file:TestUtils.java
public static String preprocessDOMContent(String currentDOM) { return currentDOM.replaceAll("#*[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}", ""); }
From source file:Main.java
public static Double Doubleformat(DecimalFormat df, Double value) { if (value == null || value.compareTo(0.0) == 0) { return 0.0; }/* w ww .j av a 2s . c o m*/ if (df == null) { df = doubleFormat; } String dfValue = df.format(value); dfValue = dfValue.replaceAll("[ ]", ""); dfValue = dfValue.replaceAll("[,]", ""); return Double.valueOf(dfValue); }
From source file:Main.java
public static double moneyToDouble(String value) { try {//from w w w . ja v a2 s .c om return Double.parseDouble(value.replaceAll("\\.", "").replaceAll(",", ".").replace("R$", "")); } catch (Exception e) { return 0; } }
From source file:Main.java
public static String removeNewLine(String value) { if (value.length() > 0) { value = value.replaceAll("[\n\r]", ""); }/* w w w . ja va 2 s .c o m*/ return value; }
From source file:Main.java
private static String dbString(String val) { if (val != null) { val = val.replaceAll("'", "''"); return "'" + val + "'"; }//from w ww . j a va 2 s .c om return "null"; }
From source file:net.acesinc.data.json.generator.types.TypeHandler.java
public static String stripQuotes(String s) { return s.replaceAll("'", "").replaceAll("\"", "").trim(); }
From source file:Main.java
/** * Returns unescape special character text. * * @param text String to be unescaped./*from www. j a v a 2 s . c om*/ * @return unescape special character text. */ public static String unescapeSpecialCharacters(String text) { text = text.replaceAll("&", "&"); text = text.replaceAll("<", "<"); text = text.replaceAll(">", ">"); text = text.replaceAll(""", "\""); text = text.replaceAll("'", "'"); text = text.replaceAll("
", "\n"); text = text.replaceAll("
", "\r"); return text; }
From source file:Main.java
public static double PecentToDouble(String percentValue) { percentValue = percentValue.replaceAll("%", ""); double newValue = 0; try {//from w w w . j a v a 2 s .c o m newValue = Double.parseDouble(percentValue); } catch (Exception e) { } return newValue; }
From source file:Main.java
public static String htmlToPlainString(String str) { if (str == null) { return ""; }// w w w .j a v a 2 s.c o m String retValue = str; retValue = retValue.replaceAll("<br/>", "\n"); retValue = retValue.replaceAll(" ", " "); retValue = retValue.replaceAll(" ", " "); retValue = retValue.replaceAll("´", "`"); // retValue = retValue.replaceAll("'", "\'"); retValue = retValue.replaceAll("\\'", "\'"); retValue = retValue.replaceAll(""", "\""); retValue = retValue.replaceAll(">", ">"); retValue = retValue.replaceAll("<", "<"); retValue = retValue.replaceAll("&", "&"); return retValue; }