fork(8) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String example = "my attachements with some name (56).jpg";
  11. Matcher m = Pattern.compile("(?<=\\()\\d+(?=\\)\\.)").matcher(example);
  12. example = m.replaceAll(r -> String.valueOf(Integer.parseInt(m.group())+1) );
  13. System.out.println( example );
  14. }
  15. }
Success #stdin #stdout 0.07s 33808KB
stdin
Standard input is empty
stdout
my attachements with some name (57).jpg