I would like to search links that contain "click" or "click here" text as anchor text.
If it matches then it should return href values.
Can someone tell me how to use regex here?
You can't use regex with PHP's DOMXPath. matches() was added in XPath 2.0, but DOMXPath only supports XPath 1.0.
You can try using contains():
//a[contains(text(), "click here")]
click here to visit ?
containsfunction. Can you tell me how to use that function to match my text?//a[contains(text(), "click here")].