is it as simple as:

Public Function SubExpressionText(extends r as regexmatch, idx as integer) as text return r.subexpressionstring(idx).totext End Function

or are there some gotchas there?

That should do it most of the time. The only “gotcha” is if the SubExpressionString’s encoding is nil or faulty (the bytes don’t conform to the given encoding).