fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String sampleText = "ABC/1111111031111111/0318*12345678\n"
  10. + "ABC/1852111031156311/1120*12345678";
  11.  
  12. String pattern = "(?<=/\\d{12,19}/)(?:0[1-9]|1[0-2])\\d{2}(?=\\*)";
  13.  
  14. System.out.println(sampleText.replaceAll(pattern, "1222"));
  15. }
  16. }
Success #stdin #stdout 0.11s 48352KB
stdin
Standard input is empty
stdout
ABC/1111111031111111/1222*12345678
ABC/1852111031156311/1222*12345678