in reply to regex patterns
The \Q and \E are regex "quotes". That means characters with special meaning lose those meanings and become literal. If you want the user to be able to use regex special characters, just remove the \Q & \E.$pattern = shift; $file = shift; open(MAT, "<$file") or die "bad file name"; $text = <MAT>; while($text =~ /\Q$pattern\E/g) { $x += 1; } print "found $x matches\n"; close(MAT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regex patterns
by dogbert (Scribe) on Jan 31, 2003 at 02:45 UTC | |
by Cabrion (Friar) on Jan 31, 2003 at 02:49 UTC |