Xpath - use contains with pattern

I have the following and am trying to figure out if there is a better approach. I know that this can be done using start-with / contains. I am testing using firefox 10, which I assume implements xpath 2. +.

Node test -

<a id="foo">
.
.
.
<a id="foo1">
.
<a id="foo2">

Is there a way to use wildcards to get foo1 / foo2 nodes.

Sort of

//a[@id =* 'foo'] 

or 

//a[contains(@id*,'foo')] 

To say, give me an "a" where the id starts with "foo" but has extra characters ... This will skip the 1st node with "foo"

I thought I saw this article, but I can not find it!

As far as I remember, the article said that xpath has a set of operators that can be used to indicate the beginning and end of a given pattern in a string.

thank

+5
source share
2

//a[@id[starts-with(., 'foo') and string-length() > 3]]
+5

, , , , :

//a[(@id!='foo') and starts-with(@id,'foo')]

. W3C XPath.

+3

All Articles