List of usage examples for java.lang String replaceAll
public String replaceAll(String regex, String replacement)
From source file:Main.java
/** * Escape all characters that would result in invalid XML when exporting the * input as an attribute value in an XML tag. * /*from ww w. ja v a 2 s . com*/ * @param input Text to escape * @return Safe text to include within XML attributes */ public static String ensureSafeXML(String input) { if (input == null) return ""; String output = input.replaceAll("&", "&"); output = output.replaceAll("&", "&"); output = output.replaceAll("<", "<"); output = output.replaceAll(">", "&rt;"); output = output.replaceAll("\"", """); return output; }
From source file:org.runway.utils.TextUtils.java
public static String getUrlFromString(String str) { String result = null;//from www . ja v a 2 s . co m str = str.replaceAll("[/\\\\]+", "\\" + "-"); result = str.replaceAll("\\s", "-"); return result; }
From source file:com.magnet.plugin.helpers.VerifyHelper.java
public static String verifyPackageName(String name) { name = name.replaceAll(">", ""); return name;/*from w ww.jav a 2 s . c o m*/ }
From source file:Main.java
public static String getDeviceName() { String manufacturer = Build.MANUFACTURER; String model = Build.MODEL;/* w w w . j ava 2 s . co m*/ if (model.startsWith(manufacturer)) { String temp = capitalize(model); temp = temp.replaceAll(" ", ""); return temp; } else { String temp = capitalize(manufacturer) + " " + model; temp = temp.replaceAll(" ", ""); return temp; } }
From source file:com.almuramc.backpack.EbeanUtil.java
private static String replaceDatabaseString(Plugin plugin, String input) { input = input.replaceAll("\\{DIR\\}", plugin.getDataFolder().getPath().replaceAll("\\\\", "/") + "/"); input = input.replaceAll("\\{NAME\\}", plugin.getDescription().getName().replaceAll("[^\\w_-]", "")); return input; }
From source file:com.ms.scombiz.solr.utils.BaseSolrQueryConvert.java
protected static String filterQuery(String value) { value = value == null ? value : value.replaceAll(invalid_chars_reg, " "); return StringFormatUtils.matcherRegex(value, REGEX); }
From source file:Main.java
public static String StringForceDigit(String sStringToFormat, int nbOfDigit) { String sStringFormated = sStringToFormat.replaceAll(" ", ""); if (sStringFormated.length() == 4) { return sStringFormated; } else if (sStringFormated.length() < nbOfDigit) { while (sStringFormated.length() != nbOfDigit) { sStringFormated = "0".concat(sStringFormated); }// w w w .j av a 2 s.c o m } return sStringFormated; }
From source file:Main.java
public static String htmlEscapeCharsToString(String html) { if (isEmpty(html)) { return html; } else {//ww w. j a va 2 s . c o m return html.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&") .replaceAll(""", "\""); } }
From source file:Main.java
public static String escapeAttributeValue(String str) { if (str == null) { return null; }//ww w .ja va 2 s . c o m return str.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">") .replaceAll("\"", """).replaceAll("'", "'"); }
From source file:com.CodeSeance.JSeance.CodeGenXML.XMLElements.Text.java
public static String escapeXMLValue(String text) { return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"); }