62,046
社区成员
发帖
与我相关
我的任务
分享
private void Method1()
{
string ptn = @"yuna123";
string output = Regex.Replace(yourInputString, ptn,
new MatchEvaluator(ReplaceCC), RegexOptions.IgnoreCase
/*or RegexOptions.None, as your need*/);
}
public static int i = 0;
private string ReplaceCC(Match m)
{
i++;
if (i == 2) // replace the second match
{
return "xxxxx";
}
else
{
return m.Value;
}
}
public static string Replace(
string input,
string pattern,
MatchEvaluator evaluator,
RegexOptions options
)
string ptn = @"yuna123";
Regex regex = new Regex(ptn, RegexOptions.RightToLeft);
string output = regex.Replace(yourInputText, "xxxxx", 1);
Regex re = new Regex("yuna123");
body = re.Replace(body,"",1);