I am trying to match a string with a non-breaking space (
) given a variable that contains the string with a regular space. The string I am looking for is the text in a HTML link/anchor and I am using Watir (note the non-breaking space).
<a onlick='DoSomthing()' href=''>Some Text</a>
There appears to be a difference between a regex created by // and by Regex.new.
Interactive Ruby says the following is true (where my_text = 'Some Text'):
/Some Text/ == Regexp.new(my_text)
Yet while this returns True:
browser.link(:text, /Some Text/).exists?
This does not:
browser.link(:text, Regexp.new(my_text)).exists?
Nor does this:
browser.link(:text, /#{my_text}/).exists?
I've also tried the following with no luck:
Regexp.new(my_text.gsub(' ', '[[:space:]]'))
Does anyone know how I can accomplish this match?