fork(2) download
  1. import java.io.*;
  2. import java.util.regex.*;
  3.  
  4. class Ideone
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String input = "ten divide by five equals to two";
  9. Pattern pattern = Pattern.compile("\\b(?:divide by|equals to)\\b|\\w+");
  10. Matcher matcher = pattern.matcher(input);
  11. while (matcher.find()) {
  12. System.out.println(matcher.group(0));
  13. }
  14. }
  15. }
  16.  
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
ten
divide by
five
equals to
two