is this helpful at all (it is in v1, sorry). It makes the a b or c optional.
This returns 1 because 1 is associated with Bravo and is the last valid match
Code: Select all
str := "<a hello> <b world> <x !> goodbye"
needle := "O)"
. "(?:(*MARK:0)<a (?P<Alpha>.+?)>)*" . "\h*" ; optional Alpha, followed by optional horz spaces
. "(?:(*MARK:1)<b (?P<Bravo>.+?)>)*" . "\h*" ; optional Bravo, followed by optional horz spaces
. "(?:(*MARK:2)<c (?P<Charlie>.+?)>)*" . ".*" ; optional Charlie, followed by optional misc chars
iPos := RegExMatch(str, needle, out)
MsgBox % out.mark
ExitApp
UPDATE:
Unfortunately the above code returns 0 for this haystack.
str := "<a hello> <x world> <c !> goodbye" ; returns 0
So it seems that once the match fails the first time (whether the others are optional or not) it does not continue any further checks. Which makes sense, but is probably not very helpful. The good news is... it does return something rather than "invalid entire match" which was happening before.