I'm trying to iterate over all matches within a string using RegExMatch within a While-Loop:
Code: Select all
FoundPos := 1
len := 0
str := "aaaa aabb bbbb bbcc cccc ccbb bbbb bbaa aaaa"
pattern := "O)b{4}"
While (FoundPos := RegExMatch(str, pattern, Match, FoundPos + len))
{
MsgBox(Match[0]) ; for AHK V1 use: MsgBox % Match[0])
len := Match.len(0)
}
Code: Select all
---------------------------
Test2.ahk
---------------------------
Error: Compile error 22 at offset 1: unmatched parentheses
Line#
001: FoundPos := 1
002: len := 0
003: str := "aaaa aabb bbbb bbcc cccc ccbb bbbb bbaa aaaa"
004: pattern := "O)b{4}"
---> 006: While (FoundPos := RegExMatch(str, pattern, Match, FoundPos + len))
007: {
008: MsgBox(Match[0])
009: len := Match.len(0)
010: }
011: Exit
012: Exit
012: Exit
The current thread will exit.
---------------------------
OK
---------------------------