fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4. class Test
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String s = "Ox 2.66 abcda 34.3 abfdasd";
  9. Pattern pattern = Pattern.compile("\\bOx\\s+(\\d*\\.?\\d+)\\s+\\S+\\s+(\\d*\\.?\\d+)");
  10. Matcher matcher = pattern.matcher(s);
  11. while (matcher.find()){
  12. System.out.println(matcher.group(1));
  13. System.out.println(matcher.group(2));
  14. }
  15. }
  16. }
Success #stdin #stdout 0.1s 49920KB
stdin
Standard input is empty
stdout
2.66
34.3