rduke15 has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I'm trying to find nodes where the class name matches a regular expression, but I cannot figure out the right syntax.
I'm using HTML::TreeBuilder::XPath, and also trying to explore with the XPather Firefox extension.
The w3.org documentation mentions a matches() function, but whatever I tried has failed.
In practice, I'm looking for li nodes with class="mw-line-even" or "mw-line-odd". (yes I could just use "or", but I would like to understand how to use regexes in such a case)
Would someone know the correct syntax for something like this:
$tree->findnodes( '//li[matches(@class, "mw-line-.*")]' );
The more perlish version of what I mean could be
$tree->findnodes( '//li[ @class =~ /^mw-line-/ ]' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::TreeBuilder::XPath and regular expressions
by rduke15 (Beadle) on Mar 29, 2010 at 12:17 UTC | |
by mirod (Canon) on Mar 29, 2010 at 12:43 UTC | |
by rduke15 (Beadle) on Mar 29, 2010 at 14:26 UTC | |
by rduke15 (Beadle) on Mar 29, 2010 at 14:37 UTC | |
by mirod (Canon) on Mar 29, 2010 at 15:06 UTC |