Seriously? I never realised that.  That makes things somewhat better, though
rather hacky imho.

- Korny

On Sun, Apr 25, 2010 at 11:59 AM, Nicholas Jefferson <
[email protected]> wrote:

> - Perl-like global operators - especially when it comes to regexps, I
>> seem to keep coming back to $1 and the like.  I'd like to think there's
>> a better way to do this, and maybe it just needs more practise on my
>> part, using matcher objects or alternative syntaxes.
>>
>
> $~, $&, $1, etc. are local:
>
> def bar
>  p [:bar, $~, $&, $1]
>  "bar" =~ /(bar)/
>  p [:bar, $~, $&, $1]
> end
>
> p [:foo, $~, $&, $1]
> "foo" =~ /(foo)/
> p [:foo, $~, $&, $1]
> bar
> p [:foo, $~, $&, $1]
>
> Thanks,
>
> Nicholas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rails-oceania%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>
>


-- 
Kornelis Sietsma  korny at my surname dot com
kornys on twitter/fb/gtalk/gwave www.sietsma.com/korny
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to