RegexMatch to have a global flag

Propose new features and changes
User avatar
RaptorX
Posts: 378
Joined: 06 Dec 2014, 14:27
Contact:

RegexMatch to have a global flag

Post by RaptorX » 02 Mar 2021, 13:48

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.
Projects:
AHK-ToolKit

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: RegexMatch to have a global flag

Post by lexikos » 02 Mar 2021, 23:21

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.

Post Reply

Return to “Wish List”