This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29817 - Typo in reluctant qualifiers example
Summary: Typo in reluctant qualifiers example
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2016-09-12 12:49 UTC by Joe Wicentowski
Modified: 2016-12-16 19:55 UTC (History)
0 users

See Also:


Description Joe Wicentowski 2016-09-12 12:49:07 UTC
At, one of the examples of reluctant qualifiers contains a typo, I believe:

> X?? matches X, once or not at all

The 2nd question mark is extraneous, since the following evaluate as true:

> matches("X", "X?")
> matches("", "X?")

Thus the 2nd question mark can be removed, as follows:

> X? matches X, once or not at all

The identical example is also present in earlier versions, and
Comment 1 Michael Kay 2016-09-12 13:34:51 UTC
The example is correct.

X?? does matches X occurring zero or one times, just as X? does. The difference between the two, as explained in the text below the example, as that X? matches the longest possible substring, while X?? matches the shortest possible.

For example, the result of

replace("AAA", "(A?)(A+)", "1=$1 2=$2")

is "1=A 2=AA"

while the result of 

replace("AAA", "(A??)(A+)", "1=$1 2=$2")

is "1= 2=AAA"

Michael Kay
Comment 2 Joe Wicentowski 2016-09-12 13:44:38 UTC
Thank you, now I understand! 

(I had tried to raise this as a question in xquery-talk first, but the list has been down since some time this summer. The maintainers of the list have been notified and are working on restoring service.)