BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
661 stars 267 forks source link

Add calculation of parent groups in regexes #2281

Closed GuntherRademacher closed 4 months ago

GuntherRademacher commented 4 months ago

These changes fix QT4 test case analyzeString-017. This requires calculation of the parent group of a regex group, for being able to decide where to put an empty match for some group within the result of fn:analyze-string.

The parent group could have been calculated while parsing the regex, however when using option j, this does not take place. So it was implemented by a separate scan of the Java regex. This however is only done when a group matches the empty string while processing the result of fn:analyze-string.

Member groups of RegExp.RegExpr has been dropped, because the same information is available from Matcher.groupCount. This change also enables proper handling of group references in fn:replace when using the j option (groups was not set in this case).