Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <a><b><![CDATA[userinput]></b><c>text of c</c><d></d><e>text of e</e></a>
  2.  
  3. Pattern pattern = Pattern.compile("<b>.*?</b>", Pattern.DOTALL | Pattern.UNICODE_CASE | Pattern.MULTILINE);
  4. Matcher matcher = pattern.matcher(input);
  5. StringBuilder builder = new StringBuilder();
  6. int lastIndex = 0;
  7. while (matcher.find()) {
  8. builder.append(input.substring(lastIndex, matcher.start()));
  9. lastIndex = matcher.end();
  10. }
  11. builder.append(input.substring(lastIndex));
  12.  
  13. <a><b><![CDATA[test 123 </b><c>inside</c>]></b><c>outside</c><d></d><e>out side</e></a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement