Text Manipulation | Page 2

RegEx 110- Example using AutoHotkey Regular Expression on naming convention

AutoHotkey Regular Expression on naming conventionI’ve found the best way to learn RegEx is to actually play with it.  For that reason I’m making a few videos that will demonstrate actual use-cases.  In this example I demonstrate applying an AutoHotkey Regular Expression on naming convention.  As I show in this video, there are a ton of different ways you can write a Regular Expression that will capture what you need.  There isn’t a “right” & “wrong” way, just make sure what you use is reliable and makes sense to you.

Video demonstrating AutoHotkey Regular Expression on naming convention

RegEx 110- Example 1-Regular Expression on naming convention

Text Manipulation | Page 2

RegEx 108-Return your match in AutoHotkey Regular Expressions match object

AutoHotkey Regular Expressions match objectNeed to get additional information about your RegExMatch?  Why not return a AutoHotkey Regular Expressions match object?  Having your data returned in an object allows for some great information like: Length, location, name of subpattern, etc.  With AHK  you can use the O) option to store the matches into an AutoHotkey object.  The below video walks through how to do it and gives you a clear example how to access it once it is created.

Create and access an AutoHotkey Regular Expressions match object

RegEx 108- Dumping your Regular Expression match into an AutoHotkey Object

Here is the code demonstrated in the video

 

Text Manipulation | Page 2

RegEx 107- Using POSIX in AutoHotkey Regular Expressions

POSIX in AutoHotkey Regular ExpressionsOnce you get used to the RegEx symbols it is pretty easy to follow however, those not familiar with it, will often be perplexed by what it is doing.  I will sometimes use POSIX in AutoHotkey Regular Expressions to help layman read my code.  While it is easier to read, it does add considerable length to the expression (but don’t confuse length with the speed of it working.  I doubt there is a correlation in this case)

POSIX (pronounced PAH-zihcks) is an acronym for Portable Operating System Interface from UNIX

Demo video using POSIX in AutoHotkey Regular Expressions

RegEx 107 Using POSIX in your AutoHotkey Regular Expression

Text Manipulation | Page 2

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