Text { public static String removeFormattingTags(String str) { StringBuffer stringBuffer = new StringBuffer(); Matcher matcher = TAG_REGEXP.matcher(str); while (matcher.find()) { matcher.appendReplacement(stringBuffer, ""); String match = matcher.group(0); switch (match) { case "<lt>": case "<gt>": stringBuffer.append(match); break; } } matcher.appendTail(stringBuffer); return stringBuffer.toString(); }  static List<String> fromCSV(final String input); static String toCSV(final Collection<String> input); static String removeTags(String str); static String removeFormattingTags(String str); static String standardize(String str); static String toJagexName(String str); static String sanitizeMultilineText(String str); static String escapeJagex(String str); static String sanitize(String name); static String titleCase(Enum o); static boolean matchesSearchTerms(Iterable<String> searchTerms, final Collection<String> keywords); static final CharMatcher JAGEX_PRINTABLE_CHAR_MATCHER; }
@Test public void removeFormattingTags() { assertEquals("Test", Text.removeFormattingTags("<col=FFFFFF>Test</col>")); assertEquals("Test", Text.removeFormattingTags("<img=1><s>Test</s>")); assertEquals("Zezima (level-126)", Text.removeFormattingTags("<col=ffffff><img=2>Zezima<col=00ffff> (level-126)")); assertEquals("", Text.removeFormattingTags("<colrandomtext test>")); assertEquals("Not so much.", Text.removeFormattingTags("<col=FFFFFF This is a very special message.</col>Not so much.")); assertEquals("Use Item -> Man", Text.removeFormattingTags("Use Item -> Man")); assertEquals("a < b", Text.removeFormattingTags("a < b")); assertEquals("a <lt> b", Text.removeFormattingTags("a <lt> b")); assertEquals("Remove no tags", Text.removeFormattingTags("Remove no tags")); }