fork download
  1. regex = /([^\s@]+)((?:@[^\s@]+)*@)([^\s@]+)/
  2. text = "aaa@xxx@bbb aaa@xxx@bbb aaa@bbb aaa@xxx@xxx@xxx@bbb"
  3.  
  4. puts(text.gsub(regex){"#{$1.upcase}#{$2}#{$3.upcase}"})
Success #stdin #stdout 0.01s 6252KB
stdin
Standard input is empty
stdout
AAA@xxx@BBB AAA@xxx@BBB AAA@BBB AAA@xxx@xxx@xxx@BBB