[Greasemonkey] Pattern matching on an attribute?

Jonathan Buchanan jonathan.buchanan at gmail.com
Wed Apr 19 23:26:44 EDT 2006


Sean LeBlanc wrote:
> I'm trying to figure out how I might pattern match on an attribute. 
> 
> Something like:
> 
> document.evaluate('//img[@src="foo*"]'), 
>  document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
>  null );
> 
> Doesn't seem to work. Is there any way to do this without getting all that
> match img and then cycling over those?
> 
> Thanks,

Does this do what you want?

//img[starts-with(@src,'foo')]

Reference:
http://www.w3.org/TR/xpath#section-String-Functions


More information about the Greasemonkey mailing list