例如:要将第一分组大写:
str = '1abc2aabbcc3aaabbbccc4'
pp str.sub(/(a{2})(b{2})/, '\1.upcase\2') # =>"1abc2aa.upcasebbcc3aaabbbccc4" 第一分组怎么没有变大写呢?
pp str.sub(/(a{2})(b{2})/, '\1'.upcase + '\2') # =>"1abc2aabbcc3aaabbbccc4" 奇怪,upcase()还是没起作用!?
pp str.sub(/(a{2})(b{2})/, $1.upcase + '\2') # =>"1abc2AAbbcc3aaabbbccc4" 使用$1而不是'\1',upcase()才起作用?