fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String path = "T1/T2\\/T3/T4"; // <-- Note how the string must be coded in Java
  11. String pattern = "(?s)(?:\\\\.|[^\\\\/])+";
  12. Pattern r = Pattern.compile(pattern);
  13. Matcher m = r.matcher(path);
  14. while (m.find()) {
  15. System.out.println(m.group(0));
  16. }
  17. }
  18. }
Success #stdin #stdout 0.07s 52412KB
stdin
Standard input is empty
stdout
T1
T2\/T3
T4