Skip to content

Instantly share code, notes, and snippets.

View tokunbo's full-sized avatar
📈
stoNkz only go up

Tokunbo George tokunbo

📈
stoNkz only go up
View GitHub Profile
@bonkydog
bonkydog / escape_xpath_single_quotes.rb
Created November 13, 2012 06:13
escape single quotes for xpath in ruby
def escape_single_quotes_for_xpath(string)
if string =~ /'/
%[concat('] + string.gsub(/'/, %[', "'", ']) + %[')] # horribly, this is how you escape single quotes in XPath.
else
%['#{string}']
end
end