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)”

text=
(
I'm recording this on 11/12/2016
01/06/2016
)

RegExMatch(text,".*(?P<Mon>\d\d)/(?P<Day>\d\d)/(?P<Year>\d\d\d\d)",Date_)
MsgBox % Date_Mon  "`n" Date_Day  "`n" Date_Year

 

Video demonstrating how to create Named subpatterns in AutoHotkey Regular Expressions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.