Ok, so I would like to do something like this:
string.gsub(regexp, output(''\0'' ,''\1'',
''\2'')
Output returns a string.
I tested it in irb and it worked ok. Now when it''s in my application,
the ''\1'' and others don''t resolve as backreferences
to the matches as
they should. How can I fix this? Or go around it?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
RoR newbie wrote:> Ok, so I would like to do something like this: > > string.gsub(regexp, output(''\0'' ,''\1'', ''\2'') > > Output returns a string. > > I tested it in irb and it worked ok. Now when it''s in my application, > the ''\1'' and others don''t resolve as backreferences to the matches as > they should. How can I fix this? Or go around it?Oh, made a typo, it shoud''ve been: string.gsub(regexp, output(''\0'' ,''\1'', ''\2'')[b])[/b] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
gsub takes a block so you can do something like this:
string.gsub(regexp) {|x, y, z| output(x, y, z) }
Not sure why your previous expression didn''t work between rails and irb
though... Are you using different ruby versions between the two
environments?
On Oct 21, 5:40 am, RoR newbie
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> RoR newbie wrote:
> > Ok, so I would like to do something like this:
>
> > string.gsub(regexp, output(''\0''
,''\1'', ''\2'')
>
> > Output returns a string.
>
> > I tested it in irb and it worked ok. Now when it''s in my
application,
> > the ''\1'' and others don''t resolve as
backreferences to the matches as
> > they should. How can I fix this? Or go around it?Oh, made a typo, it
shoud''ve been:
>
> string.gsub(regexp, output(''\0'' ,''\1'',
''\2'')[b])[/b]
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---