Hi,
I want to insert the "​" character in between each character of
a string contained in @user.email. So if the string output were
"me@mine.com", the result would be
"m​e​@​m​i​n​e​.​c​o​m".
Thanks for the info, - Dave
laredotornado wrote:
Hi,
I want to insert the "​" character in between each character of
a string contained in @user.email. So if the string output were
"me@mine.com", the result would be
"m​e​@​m​i​n​e​.​c​o​m".
Thanks for the info, - Dave
Something like this will do:
email = "me@mine.com"
email[0..-1].gsub(/./){|c| c+"​"}+email[-1..-1]
···
--
Posted via http://www.ruby-forum.com/\.
laredotornado wrote:
Hi,
I want to insert the "​" character in between each character of
a string contained in @user.email. So if the string output were
"me@mine.com", the result would be
"m​e​@​m​i​n​e​.​c​o​m".
Thanks for the info, - Dave
p "astring".split("").join("​")
regards,
Siep
···
--
Posted via http://www.ruby-forum.com/\.
Joachim Glauche wrote:
email = "me@mine.com"
email[0..-1].gsub(/./){|c| c+"​"}+email[-1..-1]
I guess you want that to be email[0..-2] not email[0..-1] (otherwise you'll
have the last character twice). Anyway, here's my gsub solution:
email.gsub(/(.)(?=.)/, '\1​')
HTH,
Sebastian
···
--
Jabber: sepp2k@jabber.org
ICQ: 205544826