When I execute the following code with certain data, it takes a long, long time (~10 seconds on a fairly fast machine) to return.
if ($text =~ /($searchString)/) { $_ = $1; s/!CR!/\n/g; print "$_\n"; } else { print "No match\n"; }
These are the values of $searchString and $text going into the regular expression. I apologize for the length, but this is as much as I've been able to narrow down the problem.
$searchString : (?:.(?!!CR!))*.?-------(?:.(?!!CR!))*.?!CR!(?:.(?!!CR! +))*.?!CR!(?:.(?!!CR!))*.?!CR!(?:.(?!!CR!))*.?node(?:.(?!!CR!))*.?!CR! +(?:.(?!!CR!))*.?id(?:.(?!!CR!))*.?NEW ALERT(?:.(?!!CR!))*.?!CR!(?:.(? +!!CR!))*.?borg(?:.(?!!CR!))*.?!CR!(?:.(?!!CR!))*.?subsys(?:.(?!!CR!)) +*.?!CR!(?:.(?!!CR!))*.?severity(?:.(?!!CR!))*.?!CR!(?:.(?!!CR!))*.?!C +R!(?:.(?!!CR!))*.?nohup(?:.(?!!CR!))*.?!CR!(?:.(?!!CR!))*.?Id(?:.(?!! +CR!))*.?!CR!(?:.(?!!CR!))*.?Team(?:.(?!!CR!))*.?!CR!(?:.(?!!CR!))*.?! +CR!(?:.(?!!CR!))*.?!CR!(?:.(?!!CR!))*.?REPORT(?:.(?!!CR!))*.?Resource +(?:.(?!!CR!))*.?slow -(?:.(?!!CR!))*.? $text : ------------------------------------------------------------!C +R!!CR!11/19/2001 16:20:23!CR!node_name[sanitized]!CR!id[987987] NEW A +LERT!CR!borg[this.also.sanitized]!CR!subsystem[this.too] ERR-5555!CR! +severity[warning] group[sanitized-host]!CR!!CR!nohup /usr/local/bin/n +otreal!CR!Id: 987987!CR!Team[TEST_Services]!CR!!CR!ACTION: Send Voice + Mail to [555-3423 555-9922]!CR!REPORT: Process syslog has crashed " +garbage garbage!CR!-------------------------------------------------- +----------!CR!!CR!
I have been looking at the output generated by use re 'debug'; but without much success. I can see that it seems to loop over the same string over and over, but I'm not sure why.
I would enormously appreciate any insight.
Examine
In reply to Regex runs for too long by examine
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |