Write a program which separates emails from other characters. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a program which separates emails from other characters.

Imagine there is a long list of usernames,emails and passwords.Write a program which output will be only the emails '@' sign. ex. input:alex || gismo4l3x | alex@email.com u77 kgghhjouy bv hhj gmail.com output: alex@email.com

25th Apr 2018, 11:28 PM
Blue Dragon
Blue Dragon - avatar
2 Answers
25th Apr 2018, 11:50 PM
LordHill
LordHill - avatar
+ 1
This is often done with regex: an example I found on stack overflow var re = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
25th Apr 2018, 11:52 PM
Alejandro Aristizabal
Alejandro Aristizabal - avatar