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
In Java 1.4 and up:
String input = "..."; Matcher matcher = Pattern.compile("[^0-9]+([0-9]+)[^0-9]+").matcher(input); if (matcher.find()) { String someNumberStr = matcher.group(1); // if you need this to be an int: int someNumberInt = Integer.parseInt(someNumberStr); }