Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

RE: Regex optimizations

by dchetlin (Friar)
on Oct 25, 2000 at 01:13 UTC ( #38223=note: print w/ replies, xml ) Need Help??


in reply to Regex optimizations

This is a good question. The answer is that the REx engine does not optimize \d{2} into \d\d.

Here's how to check:

[~] $ perl -Mre=debug -e'qr/\d{2}/' Freeing REx: `,' Compiling REx `\d{2}' size 4 first at 3 1: CURLY {2,2}(4) 3: DIGIT(0) 4: END(0) stclass `DIGIT' minlen 2 Freeing REx: `\d{2}' [~] $ perl -Mre=debug -e'qr/\d\d/' Freeing REx: `,' Compiling REx `\d\d' size 3 first at 1 1: DIGIT(2) 2: DIGIT(3) 3: END(0) stclass `DIGIT' minlen 2 Freeing REx: `\d\d'

Why doesn't it? I don't know. But as the Benchmarks above have noted, I can't imagine that difference being notable enough to really worry about.

-dlc


Comment on RE: Regex optimizations
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://38223]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2015-07-29 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls