Question

I have a string which contain tags in the form < tag >. Is there an easy way for me to programmatically replace instances of these tags with special ascii characters? e.g. replace a tag like "< tab >" with the ascii equivelent of '/t'?

Was it helpful?

Solution

string s = "...<tab>...";
s = s.Replace("<tab>", "\t");

OTHER TIPS

using System.Text.RegularExpressions;

Regex.Replace(s, "TAB", "\t");//s is your string and TAB is a tab.
public static Regex regex = new Regex("< tab >", RegexOptions.CultureInvariant | RegexOptions.Compiled);
public static string regexReplace = "\t";
string result = regex.Replace(InputText,regexReplace);

Regex patterns should do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top