fork download
  1. import java.util.regex.Pattern;
  2. import java.util.Arrays;
  3.  
  4. public class Main
  5. {
  6. public static void main(String[] args)
  7. {
  8. String target = "hello,any|body here?";
  9. char[] delim = {'^','|','-',',',']',' '};
  10. String regex = "[" + Pattern.quote(new String(delim)) + "]";
  11. String[] result = target.split(regex);
  12. System.out.println(Arrays.asList(result));
  13. }
  14. }
Success #stdin #stdout 0.08s 380160KB
stdin
Standard input is empty
stdout
[hello, any, body, here?]