s = 'lorem.ipsum@gmail.com'puts s.sub(/\A(..)(.*)@(.*)(..)\z/) { $1 + "*"*$2.length + "@" + "*"*$3.length + $4}
Standard input is empty
lo*********@*******om
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!