RegExMatch - iterate through all matches

Get help with using AutoHotkey and its commands and hotkeys
Dave_Scream
Posts: 6
Joined: 01 Jul 2016, 06:06

RegExMatch - iterate through all matches

16 Aug 2018, 05:32

Hello.
For a long time I have a question about RegExMatch, please help.

For example I have this

Code: [Select all] [Download] GeSHi © Codebox Plus

RegExMatch("abc1 abc2 abc3 abc4", "(?P<_pattern>\w*?\d)", out)


In this scenario I have 4 matches and out_pattern is "abc1"

but how to iterate through all other matches? I mean somethink like this:
out[1]._pattern should be "abc1"
out[2]._pattern should be "abc2"
out[3]._pattern should be "abc3"
out[4]._pattern should be "abc4"
MannyKSoSo
Posts: 198
Joined: 28 Apr 2018, 21:59

Re: RegExMatch - iterate through all matches

16 Aug 2018, 07:19

What you can do with this is have a while loop go through each of the matches.

Code: [Select all] [Download] GeSHi © Codebox Plus

Pos=1
While Pos := RegExMatch("abc1 abc2 abc3 abc4", "(?P<_pattern>\w*?\d)", out, Post+StrLen(out)
{
Msgbox % out
}
Return

This will give a message box for each match that is found.

Return to “Ask For Help”

Who is online

Users browsing this forum: AlphaBravo, Gabby, truekefir and 81 guests