You could split your elements by
"
character and you will get an array with param-value pairs (for example the firs element is a param and the second is its value and so on). After that you could modify only the values and reconstruct the new config string. If the order of your parameters is not strictly defined (i.e. if
fadetimeout=\"0\" could also be at different positions in the string) than you could use a
Dictionary
. Here is a quick example:
string config = "screen fadetimeout=\"0\" font=\"Courier New\" fontsize=\"11\"" +
"linesize=\"4\" theme_color1=\"-1518056\" theme_color2=\"-9674238\" ";
string[] parts = config.Split('\"');
parts[0] = parts[0].Substring(parts[0].IndexOf("screen") + 6);
Dictionary<string, string> dict = new Dictionary<string, string>();
for (int i = 0; i < parts.Length - 1; i += 2)
{
dict.Add(parts[i].Trim(), parts[i + 1]);
}
dict["fontsize="] = "10";
dict["linesize="] = "2";
dict["theme_color1="] = "-3318056";
dict["theme_color2="] = "-9655238";
StringBuilder strb = new StringBuilder("screen ");
foreach(string key in dict.Keys)
{
strb.Append(key);
strb.Append("\"" + dict[key] + "\" ");
}
string newconfig = strb.ToString();
I hope this helps. :)
Regards