List of usage examples for java.util.regex Matcher replaceAll
public String replaceAll(Function<MatchResult, String> replacer)
From source file:Main.java
@Nonnull public static String stripComments(@Nonnull String source) { Pattern pattern = Pattern.compile("#(.*)"); Matcher matcher = pattern.matcher(source); return matcher.replaceAll(""); }
From source file:Main.java
public static String replaceBlank(String str) { if (str == null) { return null; }//from w ww . j a v a 2s .co m Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); String after = m.replaceAll(""); return after; }
From source file:Main.java
public static String replaceAllBlank(String str) { if (TextUtils.isEmpty(str)) return ""; Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); String dest = m.replaceAll(""); return dest;/*w w w. jav a 2 s. c om*/ }
From source file:Main.java
public static String trimNewLine(String str) { if (TextUtils.isEmpty(str)) return ""; str = str.trim();/* w ww .jav a 2 s. c o m*/ Pattern p = Pattern.compile("\t|\r|\n"); Matcher m = p.matcher(str); String dest = m.replaceAll(""); return dest; }
From source file:com.sharpshim.yarc.util.HtmlUtil.java
public static String stripHtml(String html) { if (html == null) return ""; Matcher matcher = scriptPattern.matcher(html); html = matcher.replaceAll(""); matcher = hiddenPattern.matcher(html); html = matcher.replaceAll(""); html = html.replaceAll("\\<.*?\\>", ""); html = StringEscapeUtils.unescapeHtml4(html); html = html.replaceAll("[\n]+", "\n"); html = clearString(html);/*from w ww . ja v a 2 s.c om*/ return html.trim(); }
From source file:Main.java
public static String replaceBlank(String str) { String dest = ""; if (str != null) { Pattern p = Pattern.compile("\r"); Matcher m = p.matcher(str); dest = m.replaceAll(""); }//from ww w .j ava 2 s.co m return dest; }
From source file:Main.java
public static String removeDuplicateWhitespace(String inputStr) { String patternStr = "\\s+"; String replaceStr = " "; Pattern pattern = Pattern.compile(patternStr); Matcher matcher = pattern.matcher(inputStr); return matcher.replaceAll(replaceStr); }
From source file:Main.java
public static String filterHtml(String html) { Pattern pattern = Pattern.compile("<style[^>]*?>[\\D\\d]*?<\\/style>"); Matcher matcher = pattern.matcher(html); String htmlStr = matcher.replaceAll(""); pattern = Pattern.compile("<[^>]+>"); String filterStr = pattern.matcher(htmlStr).replaceAll(""); filterStr = filterStr.replace(" ", ""); filterStr = filterStr.replace(" ", ""); return filterStr.trim(); }
From source file:Main.java
private static String getString(String str) { String regex = "[\\/:?*<>|]"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str); return m.replaceAll("").trim(); }
From source file:Main.java
public static String subStr(String value, Integer length) { if (value == null) return null; String regEx = "<.+?>"; Pattern pattern = Pattern.compile(regEx); Matcher matcher = pattern.matcher(value); value = matcher.replaceAll(""); value = value.replace(" ", " "); if (value.length() <= length) return value; else/*from ww w . ja v a 2s . c om*/ return value.substring(0, length) + "..."; }