fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String s = "233<C:\\Users\\Grapes\\Documents\\title.png>233<C:\\Users\\Grapes\\Documents\\title.png>33";
  11. int k = 0;
  12. StringBuffer result = new StringBuffer();
  13. Matcher m = Pattern.compile("<[^<>]*>").matcher(s);
  14. while (m.find()) {
  15. m.appendReplacement(result, "<" + ++k + ">");
  16. }
  17. m.appendTail(result);
  18. System.out.println(result.toString());
  19.  
  20. }
  21. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
233<1>233<2>33