建议使用EditPadPro,其正则表达式能力是最强的
查找:(xx)_(\d+)
替换:\1\[\2\]
那就将全部内容复制到WORD里,替换完毕后再复制回来
C#编程:(当然首先你得把文本中的字符读入字符串input中)
Regex rex = new Regex(@"(?!\s)_(?
string input = "yy_1323 ljdljtoe dd_35djlgjoejs_33";
string afterRepl = "";
MatchCollection matches = rex.Matches(input);
if (matches.Count > 0)
{
foreach (Match match in matches)
{
GroupCollection group = match.Groups;
afterRepl = rex.Replace(input, "[" + group["number"].Value + "]");
}
}
afterRepl就是你要的结果字符串