Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: regex to find vowels in anyorder

by BrowserUk (Patriarch)
on Dec 19, 2011 at 15:45 UTC ( [id://944266]=note: print w/replies, xml ) Need Help??


in reply to regex to find vowels in anyorder

@words = do{ local @ARGV = 'words.txt'; <> }; chomp @words;; m[(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] and print for @words;; aboideau aboideaus aboideaux aboiteau aboiteaus aboiteaux absolutive absolutize absolutized absolutizes abstemious abstemiously abstemiousness ...

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: regex to find vowels in anyorder
by moritz (Cardinal) on Dec 19, 2011 at 16:22 UTC

    You can anchor that regex to the start of the string with ^ and have it fail faster; in practice I haven't been able to measure a difference, so either perl is clever enough, or the whole thing is determined by IO performance.

      Even excluding IO, I cannot discern any appreciable difference either. @words contains 178,000 words:

      [0] Perl> $c =0; $t = time; m[(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] and + ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time( +)-$t);; Found 1905 matches in 0.14288 seconds [0] Perl> $c =0; $t = time; m[(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] and + ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.12593 seconds [0] Perl> $c =0; $t = time; m[(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] and + ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13659 seconds [0] Perl> $c =0; $t = time; m[(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] and + ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.14437 seconds [0] Perl> $c =0; $t = time; m[(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] and + ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13993 seconds [0] Perl> $c =0; $t = time; m[(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] and + ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13856 seconds [0] Perl> $c =0; $t = time; m[^(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] an +d ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13786 seconds [0] Perl> $c =0; $t = time; m[^(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] an +d ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13947 seconds [0] Perl> $c =0; $t = time; m[^(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] an +d ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.12269 seconds [0] Perl> $c =0; $t = time; m[^(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)] an +d ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13944 seconds [0] Perl> $c =0; $t = time; m[(?=^.*a)(?=^.*e)(?=^.*i)(?=^.*o)(?=^.*u) +] and ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.12400 seconds [0] Perl> $c =0; $t = time; m[(?=^.*a)(?=^.*e)(?=^.*i)(?=^.*o)(?=^.*u) +] and ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.14011 seconds [0] Perl> $c =0; $t = time; m[(?=^.*a)(?=^.*e)(?=^.*i)(?=^.*o)(?=^.*u) +] and ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13754 seconds [0] Perl> $c =0; $t = time; m[(?=^.*a)(?=^.*e)(?=^.*i)(?=^.*o)(?=^.*u) +] and ++$c for @words; printf "Found $c matches in %.5f seconds\n", (time()-$t);; Found 1905 matches in 0.13191 seconds

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found