fork download
  1. import java.util.regex.*;
  2. import java.util.*;
  3.  
  4. class Ideone
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String s="[[Identity (philosophy)|unique identity]]";
  9. Matcher m = Pattern.compile("\\[{2}(.*)\\|(.*)]]").matcher(s);
  10. if (m.matches()) {
  11. System.out.println(m.group(1).replaceAll("\\W+", " ").trim().replace(" ", "_")); // // => Identity_philosphy
  12. System.out.println(m.group(2).trim()); // => unique identity
  13. }
  14. }
  15. }
Success #stdin #stdout 0.07s 33976KB
stdin
Standard input is empty
stdout
Identity_philosophy
unique identity