A regex will work, but xpath expression is better in general, or you
could write an xpath expression with some regex
http://www.regular-expressions.info/xpath.html
which is probably better if you are going to use regex at all.
Using Gordon's xpath exp the js to get your earthworm count should be
like:
var ew=document.evaluate("//p[contains(.,'earthworms')]/
strong",document,null,9,null).singleNodeValue;
if(!ew) return;// no earthworms node found
ew=ew.innerHTML*1;
alert("Number of earthworms is "+ew);
Where the last line that alerts the earthworm count is something more
useful.
Erik
On Oct 23, 6:36 am, Gordon Pettey <[email protected]> wrote:
> On Fri, Oct 23, 2009 at 4:33 AM, 杨大成 <[email protected]> wrote:
> > i don't see any js can operate <strong> ,
> > how about regex?
>
> I repeat: XPath. No need for a regex.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---