Extract email address from text with Regular Expression in AutoHotkey

Extract email addressRegular Expressions are incredibly helpful for day-to-day tasks!  In this short video I demonstrate how easy it is to use a Regular Expression (RegEx) in AutoHotkey to extract email addresses from text.  The first half of the video shows how I use it to parse the haystack listed in the script.  The second half of the video I make a minor tweak and adapt it to work with any program that you can copy text to the clipboard.

Below is the code I demonstrate in the video

Haystack =
hello [email protected] more text
worked and [email protected]
did too and [email protected]
this also works [email protected]
432 432 [email protected] 43432
;Send ^c ;uncomment to use in any program
;Haystack:=Clipboard ;uncomment to use in any program

Pos:=1 ;set starting position
loop, {
Pos:=Pos_Found+StrLen(mail)+1 ;move location to new position + mail lenght+ 1
IfEqual,mail,,break ;Break loop if no mail found
mails.=mail "`n"
MsgBox % mails


Extract email addresses via Regular Expression in AutoHotkey

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.