This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
At https://www.w3.org/TR/xpath-functions-31/#regex-syntax, 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, https://www.w3.org/TR/xpath-functions/#regex-syntax and https://www.w3.org/TR/xpath-functions-30/#regex-syntax.
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
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.)