Robert Klemme
10/1/2007 1:19:00 PM
2007/10/1, Sebastian Hungerecker <sepp2k@googlemail.com>:
> kazaam wrote:
> > Is there an escape charachter? I tried it so:
> >
> > result = overlook.scan(/myoverlook:\/\/\(.+?)\n/m)
>
> That would be correct if you hadn't accidentally escaped the (, too.
> A cleaner way would be to use %r{} instead of //, so that / isn't treated as a
> special character and you don't need to escape it. Like so:
> result = overlook.scan(%r{myoverlook://(.+?)\n}m)
I'd also change the RX to a more appropriate one, e.g. any of these
%r{myoverlook://(\w+)@}
%r{myoverlook://([^@]+}
You can then extract the part you are looking for from group 1.
Depends on the surrounding context which of the RX is better suited.
I'd probably prefer the fist one since it is more robust.
Kind regards
robert