1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Rep Power

    RegEx with exceptions

    I am totaly new to RegEx, but I need to extract emails with RegEx from text file

    Some difficulties:

    1. “@”symbol has been substituted for “ at ”,"AT" or "(at)"

    2. I do not need any email with domain "myoldcompany"
    I found that with these I can found any emails:
    How to do the following?

    Thanks for any help.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Paris area, France
    Rep Power
    My understanding is that you are looking for email addresses.

    Your regex will probably match a majority of email addresses, but will also probably miss many, as email addresses can be much more complicated that what you seem to think (check RFC 2822).

    I would suggest that you use the following module: Regexp::Common::Email::Address.

    A couple of years ago, I had to develop a program for validating email addresses where I could not rely on this module (because the validation rules imposed by the client were too specific in the context), I can tell you that you can quickly get into headaches. Use that module if you can.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Apr 2009
    Rep Power
    Regexp::Common::Email::Address doesn't appear to be maintained any longer. At least no updates since Jan 2005.

    Another option would be Email::Addrress which is currently being maintained.

IMN logo majestic logo threadwatch logo seochat tools logo