JavaVerbalExpressions icon indicating copy to clipboard operation
JavaVerbalExpressions copied to clipboard

How to get the startIndex and endIndex of match results?

Open josdejong opened this issue 4 years ago • 1 comments

I have to find all occurrences of dates in an email: each occurrence and the startIndex and endIndex of the occurrence. I would like to use a human-readable regex builder like JavaVerbalExpressions, but looking at the API I see no way to extract the match details like startIndex and endIndex, I only see test and testExact returning a boolean.

Is it possible to loop over all matches and get the start and end indexes and all match details (group names etc)? Thanks!

josdejong avatar Oct 25 '19 15:10 josdejong

I see the VerbalExpression class has an internal Pattern pattern property, I think exposing this pattern via a getter would give me all freedom to fine all matches and the start and end indexes.

josdejong avatar Oct 28 '19 08:10 josdejong