fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4.  
  5. class rTest {
  6. public static void main (String[] args) {
  7.  
  8. String testString = "sb.Append(\"first string to append(1) \"); sb.Append(\"second string to append(2)\");";
  9. Pattern appendPattern = Pattern.compile("\\s*(\\w+)\\.Append\\((.*?)\\);");
  10. Matcher appendMatcher = appendPattern.matcher(testString);
  11. System.out.println(appendMatcher.replaceAll("[$1 appendString: $2];"));
  12.  
  13. }
  14. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
[sb appendString: "first string to append(1) "];[sb appendString: "second string to append(2)"];