in reply to Regular expression help: why does this not match?
'?' is a regex metacharacter for optional. It doesn't match a literal '?'.
'.' is also, but it will only surprise you later. It does match literal '.'.
You can write,
to get all characters in $b taken as literal.if ($a =~ /\Q$b\E/) { # . . . }
BTW, $a and $b are special to sort, so shouldn't be chosen as user variable names.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular expression help: why does this not match?
by lokiloki (Beadle) on Jan 18, 2007 at 23:00 UTC | |
by ikegami (Patriarch) on Jan 18, 2007 at 23:49 UTC | |
by Zaxo (Archbishop) on Jan 18, 2007 at 23:06 UTC |