So I solved this, sort-of.
I ended up writing a C# program in Linux using mono that takes a single argument (oldString in the function above) and returns newString to the console. To get the value...
Type: Posts; User: rebby
Search: Search took 0.01 seconds.
Results 1 to 2 of 2