|
2003-11-11
| ||
| 02:31 | • Ticket [838711ffff] matching variables are not being set correctly status st... artifact: 26f02983ca user: dkf | |
|
2003-11-10
| ||
| 21:55 | • Closed ticket [838711ffff]. artifact: e47ade4849 user: dgp | |
|
2003-11-09
| ||
| 18:48 | • Pending ticket [838711ffff]. artifact: 0967411c49 user: msofer | |
| 10:14 | • New ticket [838711ffff]. artifact: 25ae8fa940 user: nobody | |
matching variables are not being set correctly
Closed / Invalid838711ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-11-09 10:14:00
Tcl Version :8.4.4
OS Platform :LINUX red hat 7.3
Problem Behavior: matching variables are not being set
when there is + in the end of the pattern
%regexp -all {([0-9|A-Z]*)} {31MAR+} match var
2
%puts $var
%regexp -all {([0-9|A-Z]*)} {31MAR} match var
1
%puts $var
31MAR
msoferplain2003-11-09 18:48:59
Logged In: YES
user_id=148712
There is no bug here?
Look at what is happening if you return both matches inline:
% regexp -inline -all {([0-9|A-Z]*)} {31MAR+}
31MAR 31MAR {} {}
% regexp -indices -inline -all {([0-9|A-Z]*)} {31MAR+}
{0 4} {0 4} {5 4} {5 4}
This is probably not what the programmer wanted, but it is
what he requested in the regexp: a sequence of 'ZERO or more
digits, "|" or caps', and return the matching sequence. Two
such sequences are found here: "31MAR" (wanted) and a zero
length one.
The pattern seems badly specified to me, a proper definition
of zero-length matches is at least difficult. The correct
thing would have been to request a sequence of ONE or more
such symbols (+ instead of *)
% regexp -inline -all {([0-9|A-Z]+)} {31MAR+}
31MAR 31MAR
BTW, I can imagine that the wanted regexp is actually
{([0-9A-Z]+)} - ie, that the symbol "|" should not match -
but this is second-guessing the submitter.
Assigning to another mainatiner for confirmation of this
dismissal.
dgpplain2003-11-10 21:55:57
Logged In: YES
user_id=80530
The pattern matches the empty string.
The default "greedy"
scheme of matching sucks up the
whole string as the first match, though.
Then the trailing empty string is the only
one left that can match.
Consider:
% regexp -all -inline {[0-9|A-Z]*} 31MAR+
31MAR {}
I see no bug here.
dkfplain2003-11-11 02:31:06
Logged In: YES
user_id=79902
Also consider this:
%regexp -all -inline {[0-9]+|[A-Z]+} {31MAR+}
31 MAR
Log in (anonymous is fine) to add a comment.