Regular Expressions / RegEx | Page 3

RegEx 105- Simplify RegEx with escapes in AutoHotkey Regular Expressions

escapes in AutoHotkey Regular ExpressionsUsing RegEx to identify text patterns is an awesome skill-set to have.  In the below tutorial we review some of the shortcuts /escapes in AutoHotkey Regular Expressions.  These can make your code much more reader-friendly and easier to maintain.

Here’s a cheat-sheet for some of the more popular escapes:

  • \w =word character
  • \d = digit
  • \s =white space (tab, space, etc)
  • \b = word boundary

Remember, for each of the above, you can select the inverse of them simply by capitalizing the letter.

Demo video showing how to use Shortcuts / Escapes in AutoHotkey Regular Expressions

RegEx 105- Simplifying your AutoHotkey Regular Expression with escapes

 

Regular Expressions / RegEx | Page 3

RegEx 103- Quantifiers in AutoHotkey Regular Expressions: . *+?{N}{N,M}

Quantifiers in AutoHotkey Regular ExpressionsBeing able to specif icy how many times to look for a given pattern in your RegEx is invaluable!  In this video I demonstrate how the various Quantifiers in AutoHotkey Regular Expressions work.

When working with quantifiers, just remember they are looking for X number of  items that directly precede them.  For instance, when I use the below code, I’m looking for between 3 to 5 digits in my haystack:  (\d){3,5}.

Quantifiers in AutoHotkey Regular Expressions

RegEx 103- Using Quantifiers in AutoHotkey Regular Expressions

Regular Expressions / RegEx | Page 3

RegEx 102-Using Classes & Ranges in AutoHotkey Regular Expressions: [a-z]

Ranges in AutoHotkey Regular ExpressionRegular Expressions are an amazing way to compliment your skill-set!  In this tutorial we’ll explore using classes & Ranges in AutoHotkey Regular Expressions.  In RegEx there are a ton of different ways to match your text pattern.  I’m starting off with one of the easiest to understand & follow.  Below are a few of the common usages of classes & ranges:

  • Basic usage: [12345], [abcde]
  • Ranges: [1-5], [a-e]
  • Complements “Not In”: [^6-9], [^f-z]

Ranges in AutoHotkey Regular Expression

RegEx 102- Using Ranges in your Regular Expression

Regular Expressions / RegEx | Page 3

RegEx 101-Intro to Regular Expressions in AutoHotkey- Pattern matching made easy!

Regular Expressions in AutoHotkey

Regular Expressions in AutoHotkey (RegEx) are an amazing tool to have in your toolbox!  The simplest definition I have found of Reg Ex are: “Symbols that describe a Text Pattern”.  It is more than likely that you’ve used them in the past.  Here are a few examples where you have probably used them:

  • 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

In this intro video I give a high-level overview using Regular Expressions in AutoHotkey.  The video demonstrates pattern matching by using Expressive by Alguimist.  There are several other tools specifically written in / for AutoHotkey however this one is pretty simple and does 99% of what you’ll need.  You also might use RegEx101 or hifi RegEx for aiding your pattern matching.

RegEx 101- Regular Expressions in AutoHotkey

RegEx 101-Overview of Regular Expressions in AutoHotkey