I’m parsing a relatively complex expression in Java using regexps + some manual parsing. What I’m doing right now is removing what I’ve already parsed from the string, so I have the next thing to parse right at the beginning of the string.
I would like to change this so I have a int pos variable and I don’t modify the string. However, neither the Pattern nor the Matcher classes seem to have something to mark the index of the first character to match. Is there any way to do it?
(I know that I can just pass str.substring(pos) to the Matcher, but I guess it’s much more expensive, and complicates my code a bit, since I’m using the start() and end() methods frequently).
Matcher.find(int start) would be useful for you