And if you may, make regsub() functon the same as this snippet intends.
$regsub() is not supposed to function that way. $regsubex() was added specifically for cases where the substitutions need to be made before the substitution parameter is evaluated, which is what that method calls for. in all other cases, we should (but often don't) use $regsub().