Page 1 of 1

RegexMatch to have a global flag

Posted: 02 Mar 2021, 13:48
by RaptorX
can we have a way to have regexmatch match all instances? probably by using a global flag like g?

Code: Select all

var := 
(
"test 1
test 2
test 3"
)

regexmatch(var, "Og)(test)", match)

msgbox % match.1 " " match.2 " " match.3
Its really annoying having to loop just to have a match in multiple lines of the text. And it is not consistent with regexreplace in my opinion.

Re: RegexMatch to have a global flag

Posted: 02 Mar 2021, 23:21
by lexikos
It's...annoying? Writing loop code every time? Just write a function returning an array or enumerator, and call that instead. Or use some other solution for automating the repetitive task.

Two functions which have different purposes do not need to be "consistent". RegExReplace replaces all (or limited) matches, like StrReplace. RegExMatch != RegExMatches.

If I implement this, it would likely be as a separate function with different parameters and return value. If you write your own, you can decide what features and behaviour it will have.