• Intro to AutoHotkey HotStrings with AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Intro to DOS & AutoHotkey AutoHotkey FAQ2

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

Example Webservice / API call- Yelp and working through oAuth2

Rest API Robot FrameworkBlack Bottle 2In our API webinar we discussed how oAuth2 works however there is no better way to explain it than to actually work through an example!  In the below video & code I demonstrate how to access Yelp to perform the “handshake” with oAuth1 and receive the oAuth2 authentication.  I also demonstrate using a named Regular Expression to isolate the returned token.

;~  https://www.yelp.com/developers/documentation/v3/authentication

;***********API call to get Authorization Token*******************
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("POST",EndPoint . QueryString)
data:=HTTP.ResponseText ;~ MsgBox,,title, % response
RegExMatch(data,".*access_token\x22:\s\x22(?<Token>.*?)\x22.*",Yelp_) ;RegEx to grab token
;~  MsgBox % Yelp_token

;~  https://www.yelp.com/developers/v3/manage_app?app_created=True
;~  https://www.yelp.com/developers/documentation/v3/business_search

;~  https://www.yelp.com/developers/documentation/v2/all_category_list
;~  https://www.yelp.com/developers/documentation/v2/all_category_list/categories.json
QueryString:=QueryString_Builder({"term":"restaurants","location":"Coppell, TX","categories":"chicken_wings"})

;***********API call to yelp with Credentials*******************
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("GET", EndPoint . queryString)
HTTP.SetRequestHeader("Authorization","Bearer " . Yelp_token)
Response_Data:=HTTP.ResponseText ;~ MsgBox,,title, % response
SciTE_Output(Response_Data) ;Text,Clear=1,LineBreak=1,Exit=0

;***********QueryString Builders*******************
for key, value in kvp
  queryString.=((A_Index="1")?(url "?"):("&")) key "=" value
return queryString

Black Bottle 2Video walking through the API example / oAuth2 process