PyUtils: Delay regex matching to capture static variables
As noticed by @tadej, when we enabled regex support in diff-root
we lost the ability to exclude static variables under certain circumstances (see !37189 (closed)). We now delay the regex matching as late as possible to remedy this.