List of usage examples for java.lang String replaceAll
public String replaceAll(String regex, String replacement)
From source file:Main.java
public static String stripHTML(String htmlText) { // Replace break String processed_str = htmlText.replaceAll("\\<br\\>", ""); // Remove HTML processed_str = processed_str.replaceAll("\\<.*?>", ""); // Remove () [] and their content processed_str = processed_str.replaceAll("\\[.*?\\]", ""); // Remove the XML special character processed_str = processed_str.replaceAll("\\[.*?\\]", ""); return processed_str.trim(); }
From source file:net.link.eu.vat.client.util.VATUtil.java
/** * Cleans a VAT number, ready to send to EU VAT service. * * E.g.: "BE 0446.495.156" becomes "0446495156". * * @param vatNumber the VAT number./*from w w w. j a va 2 s . com*/ * * @return the cleaned VAT number. */ @NotNull public static String cleanEnterpriseNumber(@NotNull String vatNumber) { return vatNumber.replaceAll("[^0-9]+", ""); //Remove all non-digits }
From source file:Main.java
/** * to get the Number of Chinese Characters in the input String. * @param str/*from w w w. j a v a2s . c o m*/ * @return the Number of Chinese Characters */ public static int getChineseCharNum(String str) { String regEx = "[\u4e00-\u9fa5]"; String tem = str.replaceAll(regEx, "aa"); int n = tem.length() - str.length(); return n; }
From source file:Main.java
/** * Since "&" in menu text has special meaning, we must escape it before * displaying./*from w ww . j av a 2 s. c o m*/ * * @param src * Source text. * @return Escaped text. */ public static String getEscapedMenuItemText(String src) { if (src != null && src.indexOf('&') != -1) { src = src.replaceAll("\\&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$ } return src; }
From source file:Main.java
public static String encode(String str) { if (str == null) { return null; }/* w w w.j a va2 s .c o m*/ str = str.replaceAll(">", ">"); str = str.replaceAll("<", "<"); str = str.replaceAll("\"", """); str = str.replaceAll("&", "&"); return str; }
From source file:Main.java
private static String clearLastSpace(String txt) { if (TextUtils.isEmpty(txt)) { return txt; }/*from ww w . j ava2 s .c o m*/ return txt.replaceAll("( )*$", ""); }
From source file:Main.java
public static String formatPhoneNumber(String phoneNumber) { if (phoneNumber == null) return ""; String newString = phoneNumber.replaceAll(" ", "").replaceAll("-", "").replaceAll(",", ""); return newString; }
From source file:Main.java
public static String trimmy(String str) { String dest = ""; if (str != null) { str = str.replaceAll("-", ""); str = str.replaceAll("\\+", ""); dest = str;/*from w w w.jav a 2 s. co m*/ } return dest; }
From source file:Main.java
/** * Replace all instances of <, >, &, ' " with the XML * safe strings./*from ww w . j a v a 2s.c om*/ * * @param string to convert * @return converted String */ public static String convertIllegalCharacters(String string) { String newString = new String(); newString = string.replaceAll("<", "<"); newString = newString.replaceAll(">", ">"); newString = newString.replaceAll("&", "&"); newString = newString.replaceAll("'", "'"); newString = newString.replaceAll("\"", """); return newString; }
From source file:com.vamonossoftware.core.TextUtil.java
/** * @deprecated Use org.apache.commons.lang.StringEscapeUtils.escapeHtml() * @see /*from w ww.j a va2 s . com*/ */ public static String escapeHtml(String in) { String result = in.replaceAll("<", "<"); result = result.replaceAll(">", ">"); return result; }