Re: Why is my regex so slow?
- From: carnildo@xxxxxxxxx (Mark Wagner)
- Date: Fri, 31 Oct 2008 14:54:31 -0700
I probably should have specified: the program in my first email is a
minimal sample that can reproduce the problem. The original program
is significantly longer and more complex.
On Fri, Oct 31, 2008 at 14:38, Li, Jialin <jialinli1981@xxxxxxxxx> wrote:
print "Match\n" if($target =~ /^$regex$/o);
only compile regex only once
If I understand the "o" regex modifier, that means I can't change the
regex once I've supplied it (so if standard input is
..*target.*
..*testing.*
the program will scan through the list for lines matching "testing" twice).
print "Match\n" if($target =~ /^$regex$/); # can be replace as:
print "Match\n" if($target eq $regex);
This doesn't even do what my sample does, much less the full program.
String equality is not the same thing as substring matching, and
neither can do what the regular expression '.*colou?r.*' does.
--
Mark
.
- References:
- Why is my regex so slow?
- From: Mark Wagner
- Re: Why is my regex so slow?
- From: Jialin Li
- Why is my regex so slow?
- Prev by Date: Re: Why is my regex so slow?
- Previous by thread: Re: Why is my regex so slow?
- Index(es):