Forum: Ruby about regexp...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cda3d26c2566666a0f507073b1389628?d=identicon&s=25 Kyung won Cheon (kdream95)
on 2008-11-10 05:17
>> "aaabbxccc".sub(/bb(.)c/, "\\1.upcase")
=> "aaax.upcasecc"  # I expect 'aaaXcc'

##############
# Help Me^^
##############
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2008-11-10 05:44
(Received via mailing list)
From: Kyung won Cheon [mailto:kdream95@gmerce.co.kr]
# >> "aaabbxccc".sub(/bb(.)c/, "\\1.upcase")
# => "aaax.upcasecc"  # I expect 'aaaXcc'

consider,

> "\\1.upcase"
=> "\\1.upcase"

> "\\1".upcase
=> "\\1"


try,

 "aaabbxccc".sub(/bb(.)c/) {$1.upcase}
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2008-11-10 05:45
(Received via mailing list)
Kyung won Cheon wrote:
>>> "aaabbxccc".sub(/bb(.)c/, "\\1.upcase")
> => "aaax.upcasecc"  # I expect 'aaaXcc'

 >>> "aaabbxccc".sub(/bb(.)c/) {$1.upcase}
=> "aaaXcc"
This topic is locked and can not be replied to.