fork 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. List<String> results = new ArrayList<>();
  13. while (m.find()) {
  14. results.add( m.group() );
  15. }
  16. System.out.println(String.join("|", results));
  17. }
  18. }
Success #stdin #stdout 0.1s 33768KB
stdin
Standard input is empty
stdout
,|,|*|(|)|: