Take the 2-minute tour ×

How can I create an XPath expression that works like a regex would, so that it matches instances of next? Here's an example of what I want using regex syntax:

string = 'blah_blah next&nbsp;'


I'm new to XPath, and searching through tutorials didn't help me.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

In XPath 1.0, this expression does what you want:


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.

share|improve this answer
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 Aug 26 '10 at 23:06
@Rick: You are wellcome. –  user357812 Aug 26 '10 at 23:56

Your Answer


