“remove[email protected]@@”.split(‘@’) So I get [‘test’,‘123.com’] But if it
were [email protected] the expected validation is correct But the lase two @
signs are not recognized by split So how can check that after 123.com
still there is @ sign and declare my validation as failed?
Hi
This is not the required solution Suppose the user enters [email protected]@@ or removed_ema[email protected]@ what happens? Since we cant insists
that there should be value after @ or @@
Hi
This is not the required solution Suppose the user enters [email protected]@@ or removed_ema[email protected]@ what happens? Since we cant insists
that there should be value after @ or @@
Use tmail to validate your email
It will raise an exception on basically anything except a correct
address.
And I would recommend not using an ‘@’ symbol to symbolize anything in
an
email address. It is the key component that separates the local from the
domain part of the email address and you will always run into problems.
You can see how here:
require ‘tmail’
=> true
TMail::Address.parse(‘[email protected]@@’)
TMail::SyntaxError: parse error on token “@”
from parser.y:379:in on_error' from (irb):2:in _racc_yyparse_c’
from parser.y:375:in scan' from parser.y:375:in parse_in’
from racc/parser.rb:152:in _racc_yyparse_c' from racc/parser.rb:152:in send’
from racc/parser.rb:152:in yyparse' from parser.y:366:in parse’
from parser.y:344:in parse' from /Library/Ruby/Gems/1.8/gems/tmail-1.2.3.1/lib/tmail/address.rb:84:in parse’
from (irb):2
TMail::Address.parse(‘[email protected]@’)
TMail::SyntaxError: parse error on token “@”
from parser.y:379:in on_error' from (irb):3:in _racc_yyparse_c’
from parser.y:375:in scan' from parser.y:375:in parse_in’
from racc/parser.rb:152:in _racc_yyparse_c' from racc/parser.rb:152:in send’
from racc/parser.rb:152:in yyparse' from parser.y:366:in parse’
from parser.y:344:in parse' from /Library/Ruby/Gems/1.8/gems/tmail-1.2.3.1/lib/tmail/address.rb:84:in parse’
from (irb):3
TMail::Address.parse(‘[email protected]’)
=> #<TMail::Address [email protected]>