Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# string manipulation search and replace

Tags:

string

c#

regex

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'?

like image 522
TK. Avatar asked Sep 18 '08 16:09

TK.


2 Answers

string s = "...<tab>...";
s = s.Replace("<tab>", "\t");
like image 96
Ferruccio Avatar answered Sep 28 '22 17:09

Ferruccio


using System.Text.RegularExpressions;

Regex.Replace(s, "TAB", "\t");//s is your string and TAB is a tab.
like image 24
Burkhard Avatar answered Sep 28 '22 18:09

Burkhard