I have several strings in the rough form:
[some text] [some number] [some more text]
I want to extract the text in [some number] using the
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Regex1 { public static void main(String[]args) { Pattern p = Pattern.compile("\\d+"); Matcher m = p.matcher("hello1234goodboy789very2345"); while(m.find()) { System.out.println(m.group()); } } }
Output:
1234 789 2345