Can you elaborate on your goal? Taking "xxxy"... what do you want the
string to look like?

Robby

On Mon, Jul 27, 2009 at 6:42 AM, Nik<[email protected]> wrote:
>
> Hello All!
>
> I have a string:
> str = "xxxy"
>
> and a regular expression:
> re=/y/
>
> I know that if I do a gsub!, the variable that gets passed into the
> block acts as the matched string in str; and I can do something to
> this matched string; so:
> str.gsub!(re){|s|
>  s.upcase
> }
> #=> "xxxY"
>
> But what can I do to be able to manipulate the pre-match? is it the
> $`? I tried
> str.gsub!(re){|s|
> $`.upcase
> }
> It wouldn't work.
>
> Thank you for your help!
>
> >
>



-- 
Robby Russell
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting w/Ruby on Rails

http://planetargon.com/
http://robbyonrails.com/
http://twitter.com/planetargon
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to