Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:16:47+00:00 2026-05-15T17:16:47+00:00

I have to extract all email addresses from some .txt documents. These emails may

  • 0

I have to extract all email addresses from some .txt documents. These emails may have these formats:

  1. a@abc.com
  2. {a, b, c}@abc.edu
  3. some other formats including some @ signs.

I choose ruby for my first language to write this program, but i don’t know how to write the regex. Would someone help me? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:16:48+00:00Added an answer on May 15, 2026 at 5:16 pm

    Depending on the nature of your .txt documents, you don’t have to use one of the complicated regexes that attempt to validate email addresses. You’re not trying to validate anything. You’re just trying to grab what’s already there. Generally speaking, a regex to grab what’s already there can be much simpler than a regex that needs to validate input.

    An important question is whether your .txt documents contain @ signs that are not part of an email address you want to extract.

    This regex handles your first two requirements:

    \w+@[\w.-]+|\{(?:\w+, *)+\w+\}@[\w.-]+
    

    Or if you want to allow any sequence of non-space characters containing an @ sign, plus your second requirement (which has spaces):

    \S+@\S+|\{(?:\w+, *)+\w+\}@[\w.-]+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to download some emails from my gmail. All that emails have same
I have an XML file and I need to extract testname from all the
I'm using Selenium for work and I have extract some data from //ul, unfortunately
Hi I need to run 'sed' command on file1.txt and have it extract all
I have just used htmlagilitypack to extract all link as htmlnode from an html
I have users sending emails with some text I need to extract. Each user's
I have a message queue where i add some emails. I want to extract
I'm having some issues trying to extract all the email headers in python. I
I need to extract some values from a URL, and then use these values
I have an HTML page. I would like to extract all elements whose name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.