I am trying to replace all alphanumeric characters of an email with the '#' character using the gsub
method but Ruby is inserting a backslash before the '@' character.
E.g:
"[email protected]".gsub(/[a-z0-9]/, "#")
returns "###\#@###.###"
instead of "####@###.###"
.
It returns "####@###.###"
as expected, try to:
puts "[email protected]".gsub(/[a-z0-9]/, "#")
What you see in IRB/Pry is the prevention of #@
being interpreted as string interpolation.
Please also refer to very valuable comment by @Stefan below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With