Matching of optional parts in regular expressions

Markus Elfring Markus.Elfring at web.de
Thu Jul 8 10:02:47 EDT 2004


Does this example show an error in the implementation?

% regexp {\s*(\d+)(?:%(\w+))?} {   !123!} z a b
1
% foreach X {a b} {puts "$X=|[set $X]|"}
a=|123|
b=||
% regexp {\s*(\d+)(?:%(\w+))?$} {   !123!} z a b
0
% regexp {\s*(\d+)(?:%(\w+))?} {   456%} z a b
1
% foreach X {a b} {puts "$X=|[set $X]|"}
a=|456|
b=||

I think that the specified strings must not match to the pattern.
How do you think about it?



More information about the Python-list mailing list