hello…
if i have a string '12-34-56-78', how can i replace the '78' with
‘91’…pls…help…
thanks
hello…
if i have a string '12-34-56-78', how can i replace the '78' with
‘91’…pls…help…
thanks
string = ‘12-34-56-78’
string.gsub(((string.reverse.match /(.?)-./)[1].reverse), ‘love’)
Warning: unnecessarily complicated maybe, but works. 
Later,
Vish
On 8/9/07, Monet B. [email protected] wrote:
hello…
if i have a string '12-34-56-78', how can i replace the '78' with‘91’…pls…help…
‘12-34-56-78’[-2,2] = “91”
HTH
Daniel
Vishnu G. wrote:
string = ‘12-34-56-78’
string.gsub(((string.reverse.match /(.?)-./)[1].reverse), ‘love’)
Warning: unnecessarily complicated maybe, but works.
Later,
Vish
Thanks…a lot…it works…
Your my angel in disguise…
Monet B. wrote:
Vishnu G. wrote:
string = ‘12-34-56-78’
string.gsub(((string.reverse.match /(.?)-./)[1].reverse), ‘love’)
Warning: unnecessarily complicated maybe, but works.
Later,
VishThanks…a lot…it works…
Your my angel in disguise…
Hi…Vish…
I have a question…what if the string is ‘12-34-56-56’…and i only
want to change the last substr…
it results to ‘12-34-love-love’.
pls…help
thanks…
mmm Looks like my post was lost to the ether
‘12-34-56-78’[-2,2] = “91”
HTH
Daniel
On 8/9/07, Monet B. [email protected] wrote:
the result string should be …
string = ‘123-456-856’how.???
pls help…thanks
Sorry I misunderstood.
“123-456-856”.sub( /\d+$/, “999” )
“123-456-999”
/\d+$/ Matches the last numeric digits in the string, since it’s
anchored to
the end of the string, and replaces them with the second argument.
HTH
Daniel
Daniel ----- wrote:
On 8/9/07, Monet B. [email protected] wrote:
the result string should be …
string = ‘123-456-856’how.???
pls help…thanks
Sorry I misunderstood.
“123-456-856”.sub( /\d+$/, “999” )
“123-456-999”/\d+$/ Matches the last numeric digits in the string, since it’s
anchored to
the end of the string, and replaces them with the second argument.HTH
Daniel
It works…
Thank you so much…
God bless…
Daniel ----- wrote:
mmm Looks like my post was lost to the ether
‘12-34-56-78’[-2,2] = “91”
HTH
Daniel
hi…daniel
Its just that the last substr ‘78’ will be replaced with another
string…
like ‘12-34-56-91’…
last_str = ‘856’
string = ‘123-456-123’
the result string should be …
string = ‘123-456-856’
how.???
pls help…
thanks
Daniel: that’s cool, didn’t think of that 
Vish
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs