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.
-
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.
|