fork(1) 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 test = "A man, 66 a plan, a can*()al:55 Panama";
  11. Matcher m = Pattern.compile("[^a-zA-Z0-9\\s]").matcher(test);
  12. String result = "";
  13. while (m.find()) {
  14. result += "|" + m.group();
  15. }
  16. System.out.println(result.substring(1));
  17. }
  18. }
Success #stdin #stdout 0.14s 36592KB
stdin
Standard input is empty
stdout
,|,|*|(|)|: