fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7.  
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String regex = "\\b[a-z]\\d*\\b";
  13. String s = "((x0+(2.0^x))/(21.1-x0))";
  14. List<String> matches = new ArrayList<String>();
  15. Matcher m = Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(s);
  16.  
  17. while (m.find()) {
  18. matches.add(m.group());
  19. }
  20.  
  21. for (String match : matches) {
  22. System.out.println(match);
  23. }
  24. }
  25. }
Success #stdin #stdout 0.09s 52424KB
stdin
Standard input is empty
stdout
x0
x
x0