1

I have text file with 1000s of words. This text file also contains several emails in it. I wanted to fetch all those emails only from the text file. Can someone pls help me. I have tried several ways in notepad++ but regex is not properly created to fetch emails.

Here is a Sample:

{
    {
        "freshers": [{
            "last_name": "Dharmani",
            "uid": 14429319,
            "mail": "[email protected]",
            "skill_knowns": ["7",
            "3"],
            "mobile_no": "asnbncbnabsnm",
            "hq_mark_type": "cgpa",
            "course_id": "16",
            "university_name": "gujarat technological university",
            "branch_id": "177",
            "first_name": "Anisha",
            "course_name": "BE\/B.Tech",
            "institute_state_id": "11",
            "date_of_birth": "13-October-1992",
            "last_login": "30-Nov-2015",
            "candidate_state_name": "Gujarat",
            "candidate_city_id": "43",
            "status": 1,
            "freshers_category": "20",
            "institute_state_name": "Gujarat",
            "candidate_city_name": "Vadodara",
            "institute_name": "Sardar Vallabhbhai Patel Institute of Technology, Vasad",
            "contact_no": "3012307",
            "branch_name": "Information Science\/Technology (IS\/IT)",
            "skill_academic": ["3",
            "14",
            "8",
            "3",
            "14",
            "8",
            "3",
            "14",
            "8"],
            "candidate_state_id": "11",
            "resume_path": "upload-resume\/2015\/11\/30\/resume_14429319_1448873130.pdf",
            "qualification_type": "Graduation",
            "mobile_verify": "0",
            "src": "",
            "branch_short_name": "IT",
            "created": "23-Feb-2015",
            "hq_institute_id": "294622",
            "gender": "Female",
            "fw_id": "FW16774601",
            "picture_path": "file\/9593b209f58991f2132e4ac556de28d2.jpg",
            "hq_mark": 7.8,
            "skills": "ASP.NET,C++,HTML,MicroSoft(MS)SQL,Ajax,C#,CSS,JavaSript",
            "is_resume_available": "1",
            "hq_passout_year": 2015
        },
        {
            "last_name": "Chanda",
            "uid": 14727731,
            "mail": "[email protected]",
            "mobile_no": "alsjhasljals",
            "hq_mark_type": "percentage",
            "course_id": "16",
            "university_name": "Nagpur University",
            "branch_id": "177",
            "first_name": "Ansumitra",
            "course_name": "BE\/B.Tech",
            "institute_state_id": "20",
            "date_of_birth": "05-July-1989",
            "last_login": "30-Nov-2015",
            "candidate_state_name": "Karnataka",
            "candidate_city_id": "65",
            "status": 1,
            "freshers_category": "20",
            "institute_state_name": "Maharashtra",
            "candidate_city_name": "Bangalore",
            "institute_name": "Priyadarshini College of Engineering, Nagpur",
            "contact_no": "",
            "branch_name": "Information Science\/Technology (IS\/IT)",
            "candidate_state_id": "16",
            "resume_path": "upload-resume\/2015\/09\/12\/resume_14727731_1442002613.doc",
            "qualification_type": "Graduation",
            "mobile_verify": "0",
            "src": "home_link2",
            "branch_short_name": "IT",
            "created": "15-Jun-2015",
            "hq_institute_id": "318237",
            "gender": "Female",
            "fw_id": "FW17072975",
            "picture_path": "",
            "hq_mark": 58,
            "is_resume_available": "1",
            "hq_passout_year": 2015
        },
        {
            "last_name": "mp",
            "uid": 15056653,
            "mail": "[email protected]",
            "mobile_no": "klasjklajskjasl",
            "hq_mark_type": "percentage",
            "course_id": "16",
            "university_name": "Visveswaraiah Technological University",
            "branch_id": "177",
            "first_name": "Shruthi",
            "course_name": "BE\/B.Tech",
            "institute_state_id": "16",
            "date_of_birth": "12-May-1993",
            "last_login": "30-Nov-2015",
            "candidate_state_name": "Karnataka",
            "candidate_city_id": "65",
            "status": 1,
            "freshers_category": "20",
            "candidate_sublocation_id": "6",
            "institute_state_name": "Karnataka",
            "candidate_city_name": "Bangalore",
            "job_type": "0,Full Time,0",
            "institute_name": "East West Institute of Technology (EWIT), Bangalore",
            "contact_no": "",
            "branch_name": "Information Science\/Technology (IS\/IT)",
            "candidate_state_id": "0",
            "resume_path": "upload-resume\/2015\/11\/27\/resume_15056653_1448614939.docx",
            "qualification_type": "Graduation",
            "mobile_verify": "0",
            "src": "short_reg",
            "branch_short_name": "IT",
            "created": "08-Sep-2015",
            "hq_institute_id": "1363",
            "gender": "Female",
            "fw_id": "FW17401821",
            "picture_path": "",
            "hq_mark": 66.29,
            "skills": "",
            "is_resume_available": "1",
            "hq_passout_year": 2015,
            "candidate_sublocation_name": "Basavanagudi "
        },
        {
            "last_name": "Lakshmi",
            "uid": 14521915,
            "mail": "[email protected]",
            "skill_knowns": ["6",
            "7",
            "164"],
            "mobile_no": "ajlshjahsjahs",
            "hq_mark_type": "percentage",
            "course_id": "16",
            "university_name": "Visveswaraiah Technological University",
            "branch_id": "177",
            "first_name": "Vinaya",
            "course_name": "BE\/B.Tech",
            "institute_state_id": "16",
            "date_of_birth": "14-February-1994",
            "last_login": "30-Nov-2015",
            "candidate_state_name": "Karnataka",
            "candidate_city_id": "65",
            "status": 1,
            "freshers_category": "20",
            "candidate_sublocation_id": "16",
            "institute_state_name": "Karnataka",
            "candidate_city_name": "Bangalore",
            "job_type": "0,Full Time,0",
            "institute_name": "Vivekananda College Of Engineering And Technology (VCET), Puttur",
            "contact_no": "25
        }
4
  • 2
    Please edit your question to include a sample of the text contain the emails.
    – DavidPostill
    Nov 30, 2015 at 16:42
  • 1
    Please also describe what is your desired output, and also what have you tried (with refers) and why that wasn't working Dec 1, 2015 at 5:26
  • I wanted to print list of emails only from the above mentioned text file. I have tried regex \S+?@\S+?\.\S+ but this removes emails and remaining content left however I want emails and remaining content should be removed. My regex is working in reverse order.:)
    – shitesh
    Dec 1, 2015 at 9:42
  • So you the regex! Instead of replacing it, try to select all matching instances and copy them to a new file. Writing a regex keeping only addresses would be much more complicated. Dec 22, 2015 at 3:42

1 Answer 1

1

You can try following regex

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}

I am using this same regex for my client. Hope it helps.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .