5
Reply

Most efficient way to do string substitution

Jeff Johnson

Jeff Johnson

Dec 8 2008 9:07 AM
11.4k

Before I write a byte for byte search and subsitute routine, does anyone know if there is an easy way to do this?  I want to take

 

string s1 = "database is <<db>>.";
string s2a = "db";
string s2b = "PSFDVLP"
(then do some magical code) 
System.Console.Writeline(s1);
and get the result:  "database is PSFDVLP."

This is a simplified case, I'll actually have 2 arrays of substitute variables/values that I need to swap out when a substitute variable is within "<<" and ">>".

 

Thanks.Jeff


Answers (5)