Jump to content
leuce

Regex for extracting e-mail addresses

Recommended Posts

Hello everyone

Does anyone know what is the regular expression (in AutoIt syntax) for extracting e-mail addresses?

Thanks

Samuel

Share this post


Link to post
Share on other sites

I'm not sure of the exact rules, but I think each email address must:

  • Not contain spaces
  • Contain an @
  • Contain a period with an ending (ie: .com, .org, .edu, etc)

So you could use something simple like this:

([^\s]*@[^\s]*\.[^\s]*)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

@leuce

Wikipedia says quite enough about the syntax of an email address, so, other than providing some real-World example you are working with, why don't you show us what you tried? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Posted (edited)
47 minutes ago, FrancescoDiMuro said:

@leuce

Why don't you show us what you tried?

I could do that, of course, but how would I (or you) know of the regex is any good?  Even if it manages to extract *some* e-mail addresses would not be proof that it is the proper regex for extracting *all* e-mail addresses.  The whole point of using the correct regular expression is to avoid using an expression that works only in test cases.  Are you saying that you'll tell me the correct answer only after I've given you some likely incorrect attempts? :-)

Edited by leuce

Share this post


Link to post
Share on other sites

@leuce

You can find yourself a tons of pattern on the Internet which cover in details what you are looking for.

Why ask here then? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

To kill this bird, here's the optimized regex J. Friedl published in his first edition of "Mastering Regular Expressions".  Just like he said: Enjoy!

1350608643_emailregex.thumb.jpg.65d2f7b08541c78a3ec6d61630ef20ed.jpg


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...