Dim rgx as Match = Regex.Match("abcd", "a(.*)d")
What Happens is trivial. The Regex (Type/Structure) has function (Match) that builds a Match and returns it to rgx, which is declared of type Match. I wouldn't want to change that. What I DO want to happen is the equivalent of this:
CheckInput(strInput) CheckRegex(strRegex) Dim sw as New StopWatch sw.Start Dim tmpMatch as Match = Regex.Match(strInput, strRegex) sw.Stop GlobalMessage.Add(sw.elapsedmilliseconds) GlobalMessage.Add(strCheckInput) GlobalMessage.Add(strCheckRegex) Return tmpMatch
That is just example code. But the point is, I want to override what happens when Match is called (and ALL regex functions). The best way I can imagine to do this is to create a wrapper/clone of the System.Text.RegularExpression Namespace under my own personal Namespace. That way, a user of this would Import MyRegexNamespace instead of System.Text.RegularExpressions. Everything would still work exactly the same, though, because when they call the "Regex.Match" in my namespace, my namespace really just does a bunch of stuff, and forwards the call to the System.Text.RegularExpression Namespace...
I tried and failed at this once and would like to know if there is some method of doing this already out there.