Efficient means for parsing and replacing values in T-SQL
<p>I have a lot of T-SQL queries I need to parse and replace certain values. </p>

<p>A query may look like this</p>

<pre><code>SELECT dbo.udfTest(123,'Bob') as Foo
</code></pre>

<p>or alternatively </p>

<pre><code>SELECT dbo.udfTest(123) as Foo
</code></pre>

<p>My task is to replace the number value with another given value but as I contemplate just rolling something up using the string class and doing substrings etc I start to run into lots of edge cases like this</p>

<pre><code>SELECT dbo.udfTest ( 123 ) as Foo
</code></pre>

<p>or </p>

<pre><code>SELECT [dbo].[udfTest]( 123 ) as Foo
</code></pre>

<p>or</p>

<pre><code>SELECT [dbo].[udfTest]( 123 ) as Foo1, dbo.udfTest(123) as Foo2
</code></pre>

<p>Throw in any combination of whitespace, casing, brackets, nested parenthesis and you can imagine the number of variations I would have to cover...nasty.</p>

<p>Which brings me to wondering if there is a better way? RegEx may be a play but I figured I would toss it out to get some opinions.</p>
