Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi folks, Is there anyway to debug regular expressions?
I have a regex that resolves a lookahead expression at
the beginning of the expression. It looks like the
following
( "hello Gags" =~ /^(?=hello).*[^G][^a].*$/ )&& print ("Matched") || p +rint ("Unmatched")
Basically what it's saying is that if the engine looks
ahead from the start and locates the word 'hello'
then if the rest of the string DOES NOT contain the
char 'G' followed by the char 'a' then print matched or
else print unmatched.
i.e. for the above string it should return Unmatched... but
it doesn't.

Would anyone be able to tell me what the internal string
changes to after the engine reads (?=hello) and actually
locates the first hello?
Is there anyway to debug the resolution of regexes? I'm
using the debugger but it only does statements at a time.

Thanks,
Mark.


In reply to Debugging Regexes by perlgags78

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?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-20 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found