in reply to ?! idiom in regex - que?
You might frind a read through the Extended Patterns section of the perlre manual page. But here is a brief outline ...
/E(?!F)/ matches any E followed by anything other than an F. In a replacement, the advantage is that you don't have to deal with the matched bit. ie.
$a = "this is a test\n"; $a =~ s/t(?!e)/T/g; print $a; $b = "this is a test\n"; $b =~ s/t([^e])/T$1/g; print $b;
In your example, the code is looking for three digits, followed by "not a digit", but without having to mess about with replacing back in the "£not digit".
--
Steve Marvell
|
|---|