Jeff Johnson

Jeff Johnson

  • NA
  • 23
  • 0

Most efficient way to do string substitution

Dec 8 2008 9:07 AM

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)