fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5.  
  6. /* Name of the class has to be "Main" only if the class is public. */
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String regex = "<s:message\\b[^>]*?\"code(\\d+)\"[^>]*>";
  12. String string = string = "Sample input\n"
  13. + " Some text........... <s:message code=\"code1\" arguments=\"${arg1,arg2}\" />..\n"
  14. + " some text ........\n"
  15. + " some text ....... <s:message code=\"code2\" \n"
  16. + " />...........";
  17.  
  18. System.out.println(string.replaceAll(regex, "test$1"));
  19. }
  20. }
Success #stdin #stdout 0.09s 27996KB
stdin
Standard input is empty
stdout
Sample input
    Some text........... test1..
    some text  ........
    some text  ....... test2...........