in reply to speeding up a regex
how would I do this ? e.g. assume my keyword input file would look like this
Something along these lines:
my @patterns = map { chomp; qr/\b\Q$_\E\b/ } <$filehandle>;
Is there a more efficient way of doing the regex?
There are various trade-offs; as long as you have few and simple patterns, combining them is more likely to slow things down than speed them up, because a combined pattern will cause the engine to waste a lot of effort backtracking to check alternatives. study has never been of any use to me, either. If you have a lot of patterns, you may want to look into Regexp::Assemble as a way of combining them.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: speeding up a regex
by Anonymous Monk on Jan 03, 2006 at 15:25 UTC | |
by ikegami (Patriarch) on Jan 03, 2006 at 15:44 UTC | |
by sgifford (Prior) on Jan 03, 2006 at 19:59 UTC | |
by ikegami (Patriarch) on Jan 03, 2006 at 21:07 UTC | |
by halley (Prior) on Jan 03, 2006 at 17:03 UTC | |
by Aristotle (Chancellor) on Jan 03, 2006 at 15:52 UTC | |
by Perl Mouse (Chaplain) on Jan 03, 2006 at 16:04 UTC |