fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String regex = "(?:xxxxxxx)V[0-9]+_[0-9]+_[0-9]+(?:\\.[a-z]+)?";
  11. String string = "public void doSomething() {\n"
  12. + " return \"xxxxxxxV1_0_0.yyyyyyyy\";\n"
  13. + "}";
  14. String subst = "xxxxxxxV2_0_0";
  15.  
  16. Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
  17. Matcher matcher = pattern.matcher(string);
  18.  
  19. String result = matcher.replaceAll(subst);
  20. System.out.println("Substitution result: " + result);
  21.  
  22. }
  23. }
Success #stdin #stdout 0.09s 27928KB
stdin
Standard input is empty
stdout
Substitution result: public void doSomething() {
    return "xxxxxxxV2_0_0";
}