View Issue Details

IDProjectCategoryView StatusLast Update
00020071003.1(2024)/Issue8Base Definitions and Headerspublic2026-11-18 23:36
Reporternsz Assigned To 
PrioritynormalSeverityEditorialTypeClarification Requested
Status NewResolutionOpen 
NameSzabolcs Nagy
Organizationmusl
User Reference
Section9.1 Regular Expression Definitions
Page Number179
Line Number6357
Interp Status
Final Accepted Text
Summary0002007: regular expression repetition modifier '?' in case of no match
Descriptionnew text in https://austingroupbugs.net/view.php?id=1857#c7130

 2. If an ERE contains repetitions with and without the repetition modifier '?', the precedence between the repetitions shall be:
    a. Each leftmost shortest match shall match the leftmost shortest sequence in the string, in descending priority from left to right.
 ...
 ... the ERE "(aaa??)*" matches only the first four characters of the string "aaaaa", ...

my reading of 2a implies "(aaa??)*" matches "aaaaa" as (0,0)(-1,-1) and not (0,4)(2,4).
because a no match (of a??) is more "leftmost shortest" compared to an empty match.
to consider further rules we need to establish that they are equally "leftmost shortest", but i did not find text for that.

i.e. if a no match is shorter than an empty match then "(a|aaa??)" only matches the first "a" in "aa".
Desired Actionclarify that in 2a a no match is not better than an empty (0 repetition) match (but equal, so further rules apply).
TagsNo tags attached.

Activities

nsz

2026-11-18 23:36

reporter   bugnote:0007566

another example: "ab??|ab??c" matches "a" in "abc" if non-selected repetitions are treated as 0 length and "abc" if those are skipped during 2a rule eval.

Issue History

Date Modified Username Field Change
2026-11-18 20:29 nsz New Issue
2026-11-18 23:36 nsz Note Added: 0007566