fork download
  1. import java.util.regex.*;
  2.  
  3. class Ideone
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String s = "34.1 ABC AB34.1 ABC 39.25 AB : 19.15";
  8. Pattern pattern = Pattern.compile("(?!^)\\b(?<!\\d\\.)\\d+(?:\\.\\d+)?");
  9. Matcher matcher = pattern.matcher(s);
  10. if (matcher.find()){
  11. System.out.println(matcher.group());
  12. } else {
  13. System.out.println("No match found in '" + s + "'!");
  14. }
  15. }
  16. }
Success #stdin #stdout 0.07s 52192KB
stdin
Standard input is empty
stdout
39.25