Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        String str = "This is a 23.4.123 test.";
        String[] s = str.split(" ");
        Pattern p = Pattern.compile("(\\d)+\\.(\\d)+");
        double d;
        for (int i = 0; i < s.length; i++) {
            Matcher m = p.matcher(s[i]);
            while (m.find()) {
                d = Double.parseDouble(m.group());
                System.out.println(d);
            }
        }
    }
}