fork(1) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String regex = "^([^_]+)_([^_]+)_";
  12. String string = "02_01_fEa3129E_my Pic.png";
  13. String subst = "$1/$2/";
  14.  
  15. Pattern pattern = Pattern.compile(regex);
  16. Matcher matcher = pattern.matcher(string);
  17. String result = matcher.replaceFirst(subst);
  18.  
  19. System.out.println(result);
  20. }
  21. }
Success #stdin #stdout 0.06s 33404KB
stdin
Standard input is empty
stdout
02/01/fEa3129E_my Pic.png