Xpath “ends-with” does not work

The ends-with function is part of xpath 2.0 but browsers (you indicate you’re testing with chrome) generally only support 1.0. So you’ll have to implement it yourself with a combination of string-length, substring and equals substring(@id, string-length(@id) – string-length(‘register’) +1) = ‘register’

Find out if string ends with another string in C++

Simply compare the last n characters using std::string::compare: #include <iostream> bool hasEnding (std::string const &fullString, std::string const &ending) { if (fullString.length() >= ending.length()) { return (0 == fullString.compare (fullString.length() – ending.length(), ending.length(), ending)); } else { return false; } } int main () { std::string test1 = “binary”; std::string test2 = “unary”; std::string test3 = … Read more