fork(13) download
  1. import java.util.regex.*;
  2.  
  3. class Main
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String s = "hello^world'this*has two tokens'";
  8. Pattern pattern = Pattern.compile("([a-zA-Z0-9]|'[^']*')+");
  9. Matcher matcher = pattern.matcher(s);
  10. while (matcher.find()) {
  11. System.out.println(matcher.group(0));
  12. }
  13. }
  14. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
hello
world'this*has two tokens'