s = 'lorem.ipsum@gmail.com'puts s.sub(/\A(..).*@.*(..)\z/, '\1****@****\2')
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!