There are a number of special characters for Regular Expressions. If you
want to handle situations like this without having to know about all
these characters you can use Regexp.escape(). Thus:
$ie.link(:url,
Regexp.new(Regexp.escape("selectTerritory('1',%20'select')"))).click
You can also just use Regexp.escape() in IRB to see what would be
"escaped" and therefore what special characters are in your string.
irb> Regexp.escape "javascript:PC_7_0_G6_selectTerritory('1',%20'select')"
=> "javascript:PC_7_0_G6_selectTerritory\\('1',%20'select'\\)"
Bret
Aureliano Calvo wrote:
> Escape the "(" and ")"
> The regex should be:
> /javascript.*selectTerritory\('1',%20'select'\)/
>
> Aureliano.
> PS: I haven't tried it, so you might have to escape something else. Possible
> candidates are "'", "%" and ",".
>
>
>
> Hi,
>
> I am having difficulties using regex and clicking on a link.
>
> the full link is:
>
> "javascript:PC_7_0_G6_selectTerritory('1',%20'select')"
>
> the regex I am using is:
>
> $ie.link(:url, /javascript.*selectTerritory('1',%20'select')/).click
>
> and I receive an UnknownObjectException
>
> thanks
>
> aidy
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general