C#字符串操作搜索和替换
我有一个字符串,其中包含forms的
。 有没有一种简单的方法让我以编程方式用特殊的ascii字符替换这些标签的实例? 例如用
'/t'
的ascii等价替换像""
这样的标签?
string s = "......"; s = s.Replace(" ", "\t");
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);
正则表达式模式应该可以解决问题。