About regexp


#1

“aaabbxccc”.sub(/bb(.)c/, “\1.upcase”)
=> “aaax.upcasecc” # I expect ‘aaaXcc’

##############

Help Me^^

##############


#2

From: Kyung won Cheon [mailto:removed_email_address@domain.invalid]

>> “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}


#3

Kyung won Cheon wrote:

“aaabbxccc”.sub(/bb(.)c/, “\1.upcase”)
=> “aaax.upcasecc” # I expect ‘aaaXcc’

“aaabbxccc”.sub(/bb(.)c/) {$1.upcase}
=> “aaaXcc”