On Thu, Apr 7, 2011 at 1:58 AM, 7stud -- <bbxx789_05ss / yahoo.com> wrote:
> You can also get the relative offset like this:
>
> str = "_foo_ _bar_"
>
> str.scan(/_(\w+)_/) do |curr_match|
>  ¨ÂÒåçåøð®ìáóôßíáôã>  ¨Âèïìåßíáôãè íäÛ°>  ¨Âáðôõòåíä®ãáðôõòå>  ¨Âáðôõòåó®åáãè äï üãáðôõòå>  ¨Â Û÷èïìåßíáôãèãáðôõòå¬ ÷èïìåßíáôãè®éîäåø¨ãáðôõòå©> end

That's nice!  I wasn't aware of this.  Thanks for sharing!

I also just read this in the docs:

"Note that the last_match is local to the thread and method scope of the method
that did the pattern match."

So forget my point about $~ being safer.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/