Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: What it mathches`

by Anonymous Monk
on Aug 17, 2009 at 06:36 UTC ( [id://789088]=note: print w/replies, xml ) Need Help??


in reply to What it mathches`

use re 'debug';
use re 'debug'; $_="abc def"; #$_= qq!"abc def$"!; if (/"^abc[A\b]def$"/ ){ print "\ntrue\n"; } else { print "\nfalse\n"; } __END__ Compiling REx `"^abc[A\b]def ' size 19 Got 156 bytes for offset annotations. first at 1 1: EXACT <">(3) 3: BOL(4) 4: EXACT <abc>(6) 6: ANYOF[\10A](17) 17: EXACT <def >(19) 19: END(0) anchored ""abc" at 0 (checking anchored) minlen 9 Offsets: [19] 1[1] 0[0] 2[1] 3[3] 0[0] 6[5] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[ +0] 0[0] 0[0] 0[0] 11[4] 0[0] 15[0] false Freeing REx: `"\"^abc[A\\b]def "'
use re 'debug'; #$_="abc def"; $_= qq!"abc def$"!; if (/"^abc[A\b]def$"/ ){ print "\ntrue\n"; } else { print "\nfalse\n"; } __END__ Compiling REx `"^abc[A\b]def ' size 19 Got 156 bytes for offset annotations. first at 1 1: EXACT <">(3) 3: BOL(4) 4: EXACT <abc>(6) 6: ANYOF[\10A](17) 17: EXACT <def >(19) 19: END(0) anchored ""abc" at 0 (checking anchored) minlen 9 Offsets: [19] 1[1] 0[0] 2[1] 3[3] 0[0] 6[5] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[ +0] 0[0] 0[0] 0[0] 11[4] 0[0] 15[0] Guessing start of match, REx ""^abc[A\b]def " against ""abc def "... Found anchored substr ""abc" at offset 0... Guessed: match at offset 0 Matching REx ""^abc[A\b]def " against ""abc def " Setting an EVAL scope, savestack=3 0 <> <"abc def > | 1: EXACT <"> 1 <"> <abc def > | 3: BOL failed... Match failed false Freeing REx: `"\"^abc[A\\b]def "'

Replies are listed 'Best First'.
Re^2: What it mathches`
by CountZero (Bishop) on Aug 18, 2009 at 04:20 UTC
    Did you notice? The Regex didn't even compile correctly: it failed to take into account the (nonsensical) final double quote after the '$'. Of course the regex engine has all reasons to stop reading the regex after '$' , but one would expect it to give some kind of error such as "garbage found after '$'".

    Forget the above: I missed the 'space' after the 'def'.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        You are right. I did miss the "space" after the 'def'.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

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

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

    No recent polls found