List of usage examples for java.util.regex Matcher replaceAll
public String replaceAll(Function<MatchResult, String> replacer)
From source file:Main.java
public static String removeTags(String string) { if (string == null || string.length() == 0) { return string; }/*from w w w . j a va2 s . c om*/ Matcher m = REMOVE_TAGS.matcher(string); return m.replaceAll(""); }
From source file:Main.java
private static String sanitizeString(String srcString) { Matcher matcher = pattern.matcher(srcString); String res = matcher.replaceAll("_"); return res; // Number starts allowed rightnow }
From source file:Main.java
public static String replaceSpaces(String url) { if (!url.isEmpty()) { url = url.trim();// www . j av a2 s. c o m if (url.contains(" ")) { Matcher spaces = SPACE.matcher(url); url = spaces.replaceAll("%20"); } } return url; }
From source file:Main.java
public static String a(Context var0) { String var1 = var0.getPackageName(); String var3; try {/* w ww . jav a2 s . c o m*/ ApplicationInfo var2 = var0.getPackageManager().getApplicationInfo(var1, PackageManager.GET_META_DATA); var3 = var2.metaData.getString("TencentMapSDK"); if (!TextUtils.isEmpty(var3)) { String var4 = "[&=]"; Pattern var5 = Pattern.compile(var4); Matcher var6 = var5.matcher(var3); var3 = var6.replaceAll(""); } } catch (PackageManager.NameNotFoundException var7) { var3 = "GRYBZ-ACPWV-UIGPO-U2SRZ-KRYB6-7VFTU"; } return var3; }
From source file:com.aistor.common.utils.StringUtils.java
/** * ?HTML// w ww .j av a 2 s.co m */ public static String replaceHtml(String html) { String regEx = "<.+?>"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(html); String s = m.replaceAll(""); return s; }
From source file:Main.java
public static double parseCoordinate(CharSequence string) { int sign = 1; final Matcher negsignMatcher = PAT_NEGSIGN.matcher(string); if (negsignMatcher.find()) { sign = -1;//w ww .j a v a 2 s.co m } final Matcher signMatcher = PAT_SIGN.matcher(string); string = signMatcher.replaceAll(""); final Matcher dmsMatcher = PAT_COORD_COMPONENT.matcher(string); double degrees = 0.0; for (double scale = 1.0; scale <= 3600.0 && dmsMatcher.find(); scale *= 60.0) { degrees += Double.parseDouble(dmsMatcher.group(1)) / scale; } return sign * degrees; }
From source file:net.wastl.webmail.ui.html.JavaScriptFilter.java
public static String apply(String s) { if (!initialized) { init();/*w w w .ja va2s . c o m*/ } String retval = s; for (int i = 0; i < filter.length; i++) { Matcher m = filter[i].matcher(retval); retval = m.replaceAll(substitution[i]); } return retval; }
From source file:Main.java
/** * @param str/*from w w w . jav a 2s . co m*/ * @return String. */ public static String multiSpace2singleSpace(String str) { Pattern pattern; Matcher matcher; pattern = Pattern.compile("[\\s]+"); matcher = pattern.matcher(str); return matcher.replaceAll(" "); }
From source file:Main.java
public static String encode(String str) { if (str == null) { return null; }/*from ww w. j av a2 s . c o m*/ Matcher gtMatcher = gt.matcher(str); if (gtMatcher.matches()) { str = gtMatcher.replaceAll(">"); } Matcher ltMatcher = lt.matcher(str); if (ltMatcher.matches()) { str = ltMatcher.replaceAll("<"); } Matcher quotMatcher = quot.matcher(str); if (quotMatcher.matches()) { str = quotMatcher.replaceAll("""); } Matcher ampMatcher = amp.matcher(str); if (ampMatcher.matches()) { str = ampMatcher.replaceAll("&"); } return str; }
From source file:net.wastl.webmail.ui.html.Fancyfier.java
public static String apply(String s) { if (regs == null) { init();/* w w w . j ava 2 s. c o m*/ } String retval = s; for (int i = 0; i < regs.length; i++) { Matcher m = regs[i].matcher(retval); retval = m.replaceAll(repls[i]); //retval=regs[i].substituteAll(retval,repls[i]); } return retval; }