Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

That is a veru inefficient version of /a*b/ which is likely to do a vast amount of backtracking!

Update: interesting that if you remove the character class it goes very much faster. It forces backtracking where the non-character class variant manages to fail immediately.

C:\junk>perl noname.pl Compiling REx `a*b' size 6 Got 52 bytes for offset annotations. first at 1 synthetic stclass `ANYOF[ab]'. 1: STAR(4) 2: EXACT <a>(0) 4: EXACT <b>(6) 6: END(0) floating `b' at 0..2147483647 (checking floating) stclass `ANYOF[ab]' +minlen 1 Offsets: [6] 2[1] 1[1] 0[0] 3[1] 0[0] 4[0] Guessing start of match, REx `a*b' against `aaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...'... Did not find floating substr `b'... Match rejected by optimizer Hello Freeing REx: `"a*b"' C:\junk>perl noname.pl Compiling REx `a*[b]' size 15 Got 124 bytes for offset annotations. first at 1 synthetic stclass `ANYOF[ab]'. 1: STAR(4) 2: EXACT <a>(0) 4: ANYOF[b](15) 15: END(0) stclass `ANYOF[ab]' minlen 1 Offsets: [15] 2[1] 1[1] 0[0] 3[3] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[ +0] 0[0] 6[0] Matching REx `a*[b]' against `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaa...' Matching stclass `ANYOF[ab]' against `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaaaaaaaaaaaaaaa' Setting an EVAL scope, savestack=3 0 <> <aaaaaaaaaaaa> | 1: STAR EXACT <a> can match 61 times out of 2147483 +647... Setting an EVAL scope, savestack=3 61 <aaaaaaaaaaaa> <> | 4: ANYOF[b] failed... 60 <aaaaaaaaaaa> <a> | 4: ANYOF[b] failed... 59 <aaaaaaaaaa> <aa> | 4: ANYOF[b] failed... 58 <aaaaaaaaa> <aaa> | 4: ANYOF[b] failed... 57 <aaaaaaaa> <aaaa> | 4: ANYOF[b] failed... 56 <aaaaaaa> <aaaaa> | 4: ANYOF[b] failed... 55 <aaaaaa> <aaaaaa> | 4: ANYOF[b] failed... 54 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 53 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 52 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 51 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 50 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 49 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 48 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 47 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 46 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 45 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 44 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 43 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 42 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 41 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 40 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 39 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 38 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 37 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 36 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 35 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 34 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 33 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 32 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 31 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 30 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 29 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 28 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 27 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 26 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 25 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 24 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 23 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 22 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 21 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 20 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 19 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 18 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 17 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 16 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 15 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 14 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 13 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 12 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 11 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 10 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 9 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 8 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 7 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 6 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 5 <aaaaa> <aaaaaaa> | 4: ANYOF[b] failed... 4 <aaaa> <aaaaaaaa> | 4: ANYOF[b] failed... 3 <aaa> <aaaaaaaaa> | 4: ANYOF[b] failed... 2 <aa> <aaaaaaaaaa> | 4: ANYOF[b] failed... 1 <a> <aaaaaaaaaaa> | 4: ANYOF[b] failed... 0 <> <aaaaaaaaaaaa> | 4: ANYOF[b] failed... failed... Setting an EVAL scope, savestack=3 1 <a> <aaaaaaaaaaa> | 1: STAR EXACT <a> can match 60 times out of 2147483 +647... Setting an EVAL scope, savestack=3 ... # much similar stuff omitted EXACT <a> can match 2 times out of 2147483647... Setting an EVAL scope, savestack=3 61 <aaaaaaaaaaaa> <> | 4: ANYOF[b] failed... 60 <aaaaaaaaaaa> <a> | 4: ANYOF[b] failed... 59 <aaaaaaaaaa> <aa> | 4: ANYOF[b] failed... failed... Setting an EVAL scope, savestack=3 60 <aaaaaaaaaaa> <a> | 1: STAR EXACT <a> can match 1 times out of 21474836 +47... Setting an EVAL scope, savestack=3 61 <aaaaaaaaaaaa> <> | 4: ANYOF[b] failed... 60 <aaaaaaaaaaa> <a> | 4: ANYOF[b] failed... failed... Contradicts stclass... Match failed Hello Freeing REx: `"a*[b]"'

DWIM is Perl's answer to Gödel

In reply to Re: slow regular expressions by GrandFather
in thread slow regular expressions by jesuashok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-12-04 07:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?