All the known bugs have been fixed, and both the regexes that Juerd posted last time now seem to work.
They indeed do. Actually, there is only one, the second one doesn't use a conditional but is the same regex. Here is the regex again:
%
^
\s*
( # <1>
<
\s*
([a-zA-Z:]+) # <2/>
(?:
\s*[a-zA-Z:]*
\s* = \s*
(?:'[^']*'|"[^"]*")
)*
\s*
(/\s*)? # <3/>
>
(?:[^<>]* | (?1))*
(?(3)|
<\s*/\s*\2\s*>
)
) # </1>
\s*
$
%x
And this time, everything matches (or matches not) correctly:
<foo><bar></bar></foo> # Match
<foo><bar></foo></bar> # No match
<foo><bar/></foo> # Match *
<foo><bar></foo> # No match
<foo bar=baz/> # No match
<foo bar="baz"> # No match
<foo bar="baz"/> # Match
< fooo / > # Match
<foo/>foo # No match
foo<foo/> # No match
<foo>foo</foo> # Match
<foo><bar/>foo</foo> # Match *
<a><b><c></c></b></a> # Match *
This one matches as well * (wow)
<wml>
<card id="mail" title="C: WAP POP3">
<onevent type="onenterforward">
<refresh>
<setvar name="host" value="mail.some-domain"/>
</refresh>
</onevent>
<p>
Host:
<input type="text" format="*m" name="host" value="$(host)"
+/>
<br/>
User:
<input type="text" format="*m" name="user"/>
<br/>
Pass:
<input type="password" format="*m" name="pass"/>
<br/>
<a href="pop3.cgi?host=$(host:e)&user=$(user:e)&pa
+ss=$(pass:e)">
Login
</a>
</p>
</card>
</wml>
This single regex can actually test XML well-formedness :)
(Doesn't take <?xml?> and <!DOCTYPE> etc, though)
Those with an * didn't work with the previous patch, but do now.
On a slight tangent, is anyone else interested in the idea of (as an experiment) hacking perl to use the PCRE library in place of its built-in engine? I don't think it would be all that hard.
If it were released as a module, it would be very nice. Maybe it's even possible to create pcre_s/// and pcre_m//? If not, a normal functional interface or perhaps even object oriented interface to the PCRE library would be great. I wouldn't like it replacing Perl's built-in engine.
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
-
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.
|