For example, I have a string like this:
String string = "Some random string 1aaa5 some random string";
And I want to get start and end index of a substring "1aaa5" or similar, matched by a regex pattern:
Pattern pattern = Pattern.compile("\\d\\w+\\d");
In this case, result would be 20 and 24, for start and end respectively.
Is there a way to do this in Java?