RegEx 106-Use Named subpatterns in AutoHotkey Regular Expressions

Named subpatterns in AutoHotkey Regular ExpressionsUsing Regular Expressions in AutoHotkey is awesome!  On more complex expressions, I like to use Named subpatterns in AutoHotkey Regular Expressions to, automatically, store the results in named variables which indicate what they represent.

I typically get my RegEx working properly then I go back and change the pattern to using a named subpattern.  For instance if the following was your RegEx that you got working:

(\w\w\w)/(\d\d)/(\d\d\d\d) I would go back and adapt it to:

“(?P<Mon>\w\w\w)/(?P<Day>\d\d)/(?P<Year>\d\d\d\d)”

Video demonstrating how to create Named subpatterns in AutoHotkey Regular Expressions

RegEx 106- Creating Named Subpatterns in your AutoHotkey Regular Expression

 

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

 

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

Using the Autohotkey StringSplit / StrSplit() function to slice strings

autohotkey StringSplitUsing the AutoHotkey StringSplit / StrSplit() function

AutoHotkey has some pretty cool functions for slicing strings. Not quite as robust as Python however they definitely cover the majority of needs with ease.  In the below video I demonstrate some simple usage if it as well as a way to access the Array it creates without ever saving it to a variable!  🙂

 

Tutorial demonstrating AutoHotkey StringSplit function

Using the String Split function in AutoHotkey