tags:

views:

16

answers:

1

I'm new to xpath and am searching tutorials but can't seem to figure this out, I want to do a regex type of thing where I would select something based on it matching 'next', I wrote it below using regex syntax but am not sure how to do this in xpath, sorry for the newbie question but I am seemingly not able to find out how to do this.. thanks

string = 'blah_blah next '

xpath="//a[contains(text(),'.*?next.*')]");
+1  A: 

In XPath 1.0, this expression does what you want:

//a[contains(.,'next')]

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

Function: boolean contains(string, string)

The contains function returns true if the first argument string contains the second argument string, and otherwise returns false.

For more complex matching ussing RegExp you need a XPath 2.0 processor having this built-in functions: match(), replace(), tokenize(), etc.

Alejandro
thanks.. I found a tutorial that mentioned wildcards but it was saying to use "*" which had me really confused as I saw somewhere else this was used for something else.. thanks for the pointer
Rick
@Rick: You are wellcome.
Alejandro