There are several ways to read offsets of your matched occurrences and your capturing groups.
Use inline methods to simply return the offsets - when there is no need for using
Match details or any other operations.
If you only want to get offsets of your matches, use
You can also limit your matches.
To only get offset of the first occurrence of a matched pattern, call
As any other
first() method, it throws
SubjectNotMatchedException if the subject isn't matched by your pattern.
In a similar manner you can get offsets of your capturing groups, either using
Match details or an inline method.
These two snippets below are equal to each other.
Can also be written as...
SubjectNotMatchedException if the subject isn't
matched by your pattern.
Match.group() details and inline
GroupNotMatchedException, when used with an unmatched group.