strat has asked for the wisdom of the Perl Monks concerning the following question:
I've just got some code to enhance, and have found the following lines (shortened):
I can't understand why this pattern matches $line, because a length can be given with {3,}, while [...] means alternatives.C:\work\perl\Net\ldap\replicationClient\backup>perl my $line = "Time: 174657\n"; # line has to be in this format: xxx*:* (xxx are letters, * ser any +signs) if ($line =~ /^([a-zA-Z_)[3,].*?):(.*)/) { print "$1: $2\n"; } ^Z Time: 174657
Is [3,] under certain circumstances really the same as {3,}, or is perl really so clever?
I expected everything else than a match (included even Syntax errors because of the first [...)
Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange regex-behaviour
by broquaint (Abbot) on Mar 11, 2002 at 17:17 UTC | |
|
Re: Strange regex-behaviour
by seattlejohn (Deacon) on Mar 11, 2002 at 17:23 UTC | |
|
Re: Strange regex-behaviour
by erikharrison (Deacon) on Mar 11, 2002 at 21:07 UTC | |
|
Re: Strange regex-behaviour
by strat (Canon) on Mar 12, 2002 at 10:58 UTC |