|
2026-10-22
| ||
| 17:19 | • Ticket [1230836fff] Check independency of subpatterns status still Closed wi... artifact: 2e2cc56e88 user: serhiy.storchaka | |
|
2026-10-11
| ||
| 10:52 | • Closed ticket [1230836fff]. artifact: 2c80043deb user: serhiy.storchaka | |
| 10:51 | • Ticket [1230836fff]: 3 changes artifact: a2a0b37952 user: serhiy.storchaka | |
|
2005-07-01
| ||
| 09:45 | • New ticket [1230836fff]. artifact: 6c34b509a2 user: elfring | |
Check independency of subpatterns
Closed / Duplicate1230836fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 41 days ago
Descriptionplain2005-07-01 09:45:38
I convert the discussion "non-greedy is too greedy" into
this bug report.
http://groups.google.de/group/comp.lang.tcl/browse_frm
/thread/fd3fa4545458bbf7/0026661d93360192
Pattern examples:
% regexp {^(\d+),(.+?),} 11,A,B,C X Y Z
1
% puts "a) $Y|$Z"
a) 11|A,B
% regexp {^(\d+?),(.+?),} 12,A,B,C X Y Z
1
% puts "b) $Y|$Z"
b) 12|A
% regexp {^..,(.+?),} 13,A,B,C X Y
1
% puts "c) $Y"
c) A
Why can the change to a lazy quantifier in the first part
change the match of the capturing parentheses in the
second part?
- Are there any flags in the processing not reset when
the first comma is reached?
- Does the expression compiler generate a FSM with
unexpected states?
serhiy.storchakawiki2026-10-11 10:51:38
Documented: \d+ is the first quantified atom, so the whole RE prefers the
longest match, and (.+?) is fitted within it. Workarounds:
(?:^(\d+),(.+?),){1,1}? or ^(\d+),([^,]+),; both give
A. The docs are clarified in branch
doc-re-syntax-preference. Duplicate of [219219ffff].
serhiy.storchaka Closed ticket [1230836fff].
[History diff]2026-10-11 10:52:40
serhiy.storchaka Ticket [1230836fff]: 3 changes
[History diff]2026-10-22 17:19:24
Log in (anonymous is fine) to add a comment.