“aaabbxccc”.sub(/bb(.)c/, “\1.upcase”)
=> “aaax.upcasecc” # I expect ‘aaaXcc’
##############
Help Me^^
##############
“aaabbxccc”.sub(/bb(.)c/, “\1.upcase”)
=> “aaax.upcasecc” # I expect ‘aaaXcc’
##############
##############
From: Kyung won Cheon [mailto:[email protected]]
consider,
“\1.upcase”
=> “\1.upcase”
“\1”.upcase
=> “\1”
try,
“aaabbxccc”.sub(/bb(.)c/) {$1.upcase}
Kyung won Cheon wrote:
“aaabbxccc”.sub(/bb(.)c/, “\1.upcase”)
=> “aaax.upcasecc” # I expect ‘aaaXcc’
“aaabbxccc”.sub(/bb(.)c/) {$1.upcase}
=> “aaaXcc”
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