Hi Cay,
Thanks for mentioning this. It's good to know that adding this provides value to
people who are actually trying to use this stuff (as opposed to adding stuff merely
for the sake of completeness, as often seems to arise).
I've added some notes to JDK-8065554.
Looking at this more closely, it seems to me that MatchResult ought to include more
match-result-related information that's currently only in Matcher, namely:
1. whether there was a match at all
2. hitEnd
3. requireEnd
If you have any thoughts on these, please let me know.
s'marks
On 12/2/20 2:53 AM, Cay Horstmann wrote:
Hello, I'd like to raise awareness for
https://bugs.openjdk.java.net/browse/JDK-8180352
https://bugs.openjdk.java.net/browse/JDK-8072984
https://bugs.openjdk.java.net/browse/JDK-8065554
These all ask for MatchResult.group(String name). What they don't mention is that
this is more urgent in light of the methods
Stream<MatchResult> Matcher.results() //
https://bugs.openjdk.java.net/browse/JDK-8071479
Stream<MatchResult> Scanner.findAll(Pattern pattern) //
https://bugs.openjdk.java.net/browse/JDK-8072722
In particular, Matcher.results() seems a cleaner way of collecting match results
than calling while (matcher.find()).
But then MatchResult needs to support the same queries that Matcher provides. I
believe the only missing one is group(String name).
Cheers,
Cay
NB. There are related requests that ask for finding group names in patterns, or for
correlating group names and numbers. I have formed no opinion on their merits.