fork download
  1. s = "Thomas_J_Perkins"
  2. puts s.sub(/^(\p{L}+)(?:_\p{L}+)*_(\p{L})\p{L}*$/, "\\1_\\2")
Success #stdin #stdout 0.05s 9784KB
stdin
Standard input is empty
stdout
Thomas_P