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.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. final String regex = "(?m)^(A[0-9]{6})001";
  13. final String string = "A00233400193445 123394001\n\n"
  14. + "A83485800193471 982001134";
  15.  
  16.  
  17. System.out.println(string.replaceAll(regex, "$1002"));
  18. }
  19. }
Success #stdin #stdout 0.06s 33720KB
stdin
Standard input is empty
stdout
A00233400293445 123394001

A83485800293471 982001134