Using a Regular Expression (RegEx) to Find a URL and not an email address

Find a URL and not an email addressA subscriber reached out to me (after trying for a few hours) for some help on creating a Regular Expression to pull-out URLs from text.  Specifically not including email addresses.  Since he gave it a solid try I wanted to help him out.  I did a google search and found this post which had the RegEx pattern for finding a URL and not an email address.  I then took the pattern and put it on Regular Expressions 101 to make sure it would work in AutoHotkey.   After that I adapted it to AutoHotkey code (see below) using RegExMatch.

Find a URL and not an email address

Code to Find a URL and not an email address

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Lorem ipsum [email protected] dolor sit amet, (555)555.8957 consectetuer adipiscing elit. @recruiting  lorem ipsum
dolor sit elit.
dolor sit elit.
Pos:=1 ;set starting point

Loop, {
  ;Regex Pattern for URLs borrowed from
  Found_Pos:=RegExMatch(Text,"i)((http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\[email protected]?^=%&\/~+#-])?)",Obj,Pos)
  Pos:=Found_Pos+(StrLen(obj)+1) ;Set next start position
  URLs.=obj "`r" ;add to emails variable
  If not OBJ ;If not found break Loop
MsgBox % URLs


AutoHotkey Webinar- Using AHK string functions in Excel

AHK In this webinar we walked through using AutoHotkey String functions in Excel.

Script Highlight:  Pull data about your computer with WMI by shajul.  Forum post and my link to the zipped files of the separate scripts I wrote

Video Hour 1 & 2 : AHK string functions in Excel

Books on RPA (Robotics Process Automation) that I mentioned in the webinar

Below are links to books I showed during the webinar. I put them into two groups (those I like/recommend and those I don’t). I’m more of a “glass is half-full” kind of guy and think technology is good. The books I don’t recommend were much more negative towards technology. While I don’t recommend them, I think time will tell who is right/wrong.  Personally any of the following you buy I’d try and buy as used.  Many are pretty expensive new (probably because of the small market size)

Recommended Robotics Process Automation books

Service Automation: Robots and the Future of Work 2016 -Great book!
Robotic Process Automation and Risk Mitigation: The Definitive Guide 2017
Robotic Process and Cognitive Automation: The Next Phase 2018 -Great book!
The Singularity Is Near: When Humans Transcend Biology 2019 – very interesting
Life After Google: The Fall of Big Data and the Rise of the Blockchain Economy 2018 – some wild ideas here
The Human Advantage: The Future of American Work in an Age of Smart Machines 2018
The Glass Cage: How Our Computers Are Changing Us 2015
Managing IT as a Strategic Resource 1997
Beyond the IT Productivity Paradox 1999 – old but still interesting

Not recommended but still on the RPA topic

In The Age Of The Smart Machine: The Future Of Work And Power 1989
The Lights in the Tunnel: Automation, Accelerating Technology and the Economy of the Future 2009
A Dangerous Master: How to Keep Technology from Slipping Beyond Our Control 2015
Rise of the Robots: Technology and the Threat of a Jobless Future 2016


We also mentioned using ternary operators

and Alternate Data Stream as data storage

Here’s the code Jackie walked through.

username := "Jackie"

msgbox % "Name: " username "`nPassword: " password()
  FilePath := A_ScriptFullPath
  IniRead, Var, %FilePath%:Stream:$DATA, Settings, Pass, error
  If (Var="error"){
    InputBox, Var , New, Please enter password, HIDE
    IniWrite, %Var%, %FilePath%:Stream:$DATA, Settings, Pass
  return Var


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

RegEx 111) Ignore Whitespace in AutoHotkey Regular Expression

Ignore Whitespace in AutoHotkey Regular ExpressionAutoHotkey Merchandise-White Stress ballLong Regular Expressions can be very difficult to read and revise when you come back to it later.  Using the X) option allows you to Ignore Whitespace in AutoHotkey Regular Expression and insert comments as well as spread out your RegEx over multiple lines.

Below is the example code I use to ignore the whitespace in AutoHotkey RegEx which is demonstrated in the video below.  It is a great way to make your code easier to read & maintain.  It may take a few months until you revisit your RegEx but, when you do, you’ll thank me for it!

#SingleInstance, Force
{"items":[{"id":3866967518001,"name":"TechDays","referenceId":null,"playsTotal":null},{"id":3869639371001,"name":"Sensitivity and Selectivity in Low Power RF","referenceId":"0_4f50771k","playsTotal":null},{"id":3869653908001,"name":"Low Power RF Developer - Wireless Glue Networks Inc.","referenceId":"0_wraewmky","playsTotal":null},{"id":3869704547001,"name":"The Babelfish may Soon be Science Fact","referenceId":"0_m73cr9uf","playsTotal":null},{"id":3873942948001,"name":"Xilinx FPGA 向け電源設計ツール","referenceId":"0_w7mv8jwm","playsTotal":null},{"id":3880705798001,"name":"FORAPPROVAL_EELive_Demo20_DLP_FORAPPROVAL","referenceId":null,"playsTotal":2},{"id":3880723945001,"name":"EELive_Demo22_Low_Power_Vision","referenceId":null,"playsTotal":1},{"id":3881779779001,"name":"UCC28711 10mW 소모 전력 데모","referenceId":"0_8ejutfdv","playsTotal":null},{"id":3870946516001,"name":"LM5113 Enhancement Mode GaN FET Half-Bridge Driver Demo","referenceId":"0_wuof80ce","playsTotal":301},{"id":3907785832001,"name":"C6A8168 C6-Integra Processor Overview (Standard - Small)","referenceId":null,"playsTotal":null}],"page_number":0,"page_size":10,"total_count":4574}

RegExMatch(response, "xO)^" ;x=Ignore Whitespace in AutoHotkey Regular Expression, O store in object
	. "(?:\{""items"":\[)" ;remove early part not wanted-not capture using ?:
	. "(?P<json_Videos>.*)" ; grabbing json of videos
	. "(?:\],""page_number"":(?P<Page_Numb>\d{1,5}),)"  ;Page number looping through
	. "(?:""page_size"":(?P<Vids_Per_Page>\d{1,3}),)"  ;videos per page
	. "(?:""total_count"":(?P<Total_Numb_Vids>\d{1,5})" ;Total count of videos
	. "\})", Vids) ;closing out regexmatch

MsgBox,,total numb vids, % vids.Total_Numb_Vids
MsgBox,,json for videos, % vids.json_Videos
MsgBox,,vids per page, % vids.Vids_Per_Page
MsgBox,,Page_Numb, % vids.Page_Numb

Ignore Whitespace in AutoHotkey Regular Expression