fork download
  1. import java.util.regex.*;
  2. public class Main {
  3. public static final String EXAMPLE_TEST = "Answer to life 42. Take the first right onto Embarcadero Rd 12.43 mi";
  4.  
  5. public static void main(String[] args) {
  6. Pattern pattern = Pattern.compile("(\\d+(.\\d+)?) (mi|ft)");
  7. Matcher matcher = pattern.matcher(EXAMPLE_TEST);
  8. if(matcher.find()) {
  9. System.out.println(matcher.group(1));
  10. }
  11.  
  12. }
  13. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
12.43