Forum Discussion

sathyarajg's avatar
Occasional Contributor
7 years ago

Regex-xpath-how to extract a substring from string?

I have the following xpath match in my test suite,




Result :


I want the result as 


I tried the below xpath expression with reg ex,


concat(join(tokenize(//html/body/div[2]/table/tbody/tr[td/b[text()='NewsV1']]//td[4]/a[1]/@href[1], '/' )[position() < 4],'/'),'/')


This i am getting the error as invalid xpath expression.kindly suggest me why this xpath expression is incorrect and help me to form the correct syntax to get the substring properly.


I cant write this groovy script to get this..i am facing CDATA error because of http response.


So i want the suggestion for xpath+regex


Thanks for advance .same problem in ready API too