Re: string matching specific number of times
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 30 Sep 2005 12:29:49 GMT
tester <tester@xxxxxxxxxxx> wrote in comp.lang.perl.misc:
> Hi All,
>
> My CPU taking 100% if I try to match more than the existing number of
> specific matches in a string. Script is ...
>
> my $something = "this is a test, just test, no kidding, small test, but
> error in test. over over";
> if ($something =~ m/((.*)test(.*)){5}/){
> print "number of matches are 5, successful";
> }
> else{
> print "no 5 matches, failure";
> }
>
> String "test" is repeated only 4 times in $something but if I am trying
> to check whether the $something has 5, my CPU taking 100%. What is the
> issue?
Probably excessive backtracking. Lots of alternatives have already been
proposed.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- References:
- string matching specific number of times
- From: tester
- string matching specific number of times
- Prev by Date: Re: string matching specific number of times
- Next by Date: Re: Perl calculate and average problem
- Previous by thread: Re: string matching specific number of times
- Next by thread: regex replace credit card numbers with *
- Index(es):
Relevant Pages
|