See these code below:
<code a:>
Code: Select all
;(1) Match is not found, and v will be ""
RegExMatch('x','y',&v)
;(2)A Match is found, and both will be a matchObj in v this time, and v[] is ""
RegExMatch('x','y?',&v)
,RegExMatch('x',"",&v)
Code: Select all
;(1) A subPattern is found, and v['c'] is ""
;It's the with v[] in <code a>. It's right.
RegExMatch('x','(?<c>y?)',&v)
,OutputDebug(v['c'])
;(2) SubPattern is not found, but v['c'] is also ""
;Both results are the same, this time.
;This is inconsist with <code a> where both results are different.
;It is not reasonable.
; I think v['c'] is better to return 0 this time.
RegExMatch('x','(?<c>y)|.*',&v)
,OutputDebug(v['c'])
;(3) SubPattern name is not found and it will return unset.
;At least, I wish v['f'] would return unset, just like v.f??XXX
RegExMatch('x','(?<c>y)|.*',&v)
;,OutputDebug(v['f'])
By the way, the suggestion is backward compatible. Because both "" and 0 works equally for an If keyword.