Example Webservice / API call- Yelp and working through oAuth2

In 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.

Video walking through the API example / oAuth2 process

 

 

 

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

 

Extract email addresses via Regular Expression in AutoHotkey

Extract email addresses with Regular Expression in AutoHotkey

RegEx 112 – Using RegExReplace in AutoHotkey to manipulate date structure

RegExReplace in AutoHotkeyIn this tutorial I use RegExReplace in AutoHotkey to move the days to the beginning of the date format and months to the middle.  While it is pretty straight-forward, I managed to forget to add something to my script which forced me to trouble-shoot.  I talked through a bit of the process of how I typically will work on a Regular Expression.

I think most people working in Regular Expressions don’t get it right the first time. They often need to make little tweaks to get it right.  😉  Keep at it!

Video demonstrating using RegExReplace in AutoHotkey to manipulate dates

RegEx 112 RegExReplace in AutoHotkey- Example moving around Charchaters

AutoHotkey webinar on Regular Expressions- Learn some great RegEx Tips!

This AHK Webinar focused on Regular Expressions.

AutoHotkey Webinar Videos

AutoHotkey webinar

Video of Hour One

Video of Hour two

Content from AutoHotkey Webinar

What are Regular Expressions?

  • “Symbols that describe a text pattern”
  • Pattern matching- Chances are extremely high that you’re familiar with this.
    • Using * or ? when looking for a file in Windows Explorer
    • Validate format ( email, phone number, zip code, two-letter state abbreviation)
    • Search & replace text in files
    • Count # of times pattern exists
    • Find duplicate words

When to use RegEx vs. other functions like StrReplace(), InStr()

  • When Haystack is smaller- probably doesn’t matter
  • StrReplace() and InStr() are faster than RegEx but simpler

General rule-of-thumb:  Use RegEx when your pattern is more complex

RegExMatch vs. RegEx Replace

There is definitely overlap between the two tools however here is a high-level view of their “niche” areas & important their differences:

RegExMatch()

  • Tool for finding, saving & extracting specific matches
  • Once your match is found, RegExMatch has done it’s job and stops processing. To continue you need to restart beginning where your last match was found
  • Does NOT affect original data
  • Returns found position
  • O) Match pattern can be returned as an object/pseudo array for easy access

RegExReplace()

  • Modification tool allows you to change (re-order/structure, swap out) your data
  • Does not stop after finding first match. Unless otherwise stipulated it proceeds through the entire haystack
  • Returns Newstring:= (altered) string

Common / Helpful RegEx Options

  • m) Multiline (treats each line as separate text)
  • U) Ungreedy (stops at first match)
  • x) Ignore whitespace (great for multiline RegEx)
  • C) Auto-callout mode (help show where you are in your Expression)
  • O) (in RegExMatch) returns match in object

Quantifiers

  • * 0 or more times
  • ? 0 or 1 times
  • + 1 or more times
  • {N} exactly N times
  • {N,} N or more times
  • {N,M} N through M times

Characters Needing Escape

  • \ . * ? + [ { | ( ) ^ $”

Ranges

  • [1-5], [a-e]

Special Characters

  • ^ Start of Line
  • $ End of Line
  • . Any character

Escapes

  • \d  Digit              \D   Non-digit
  • \s Whitespace    \S    Non-whitespace
  • \w “Word“          \W Non-“Word”
  • \n  New Line       \t  Tab
  • \r  Line Return   \b  Boundary
  • \QLiteral\E
  • \x  where x is Hex  \x22=“

Regular Expression Resources

AutoHotkey Help

Tools Built in AutoHotkey

Websites to test dynamic code

Additional Resources

Check out more AutoHotkey webinars

Sign-up for future ones here