ruby on rails - Hide part of an email address -
what's best way hide 4 characters before @ sign of email address using ruby eg
fakename@example.com = fake####@example.com
it's going used in view when display list of testimonials , don't want display whole address.
my long way round attempt:
name = 'fakename@example.com'.split("@")[0] email = 'fakename@example.com'.split("@")[1] new_address = name [0..-4] + "@" + email
try below handle short names a@example.com
'fakename@example.com'.gsub(/.{0,4}@/, '####@')
Comments
Post a Comment