これは入力文字列23x * y34x2です。" * "すべての数字の後に文字が続き、すべての文字の後に数字が続く後に(空白で囲まれた星)を挿入したいと思います。したがって、私の出力文字列は次のようになります23 * x * y * 34 * x * 2。
これは、仕事をする正規表現です:@"\d(?=[a-z])|[a-z](?=\d)"。これは私が書いた関数で、を挿入し" * "ます。
Regex reg = new Regex(@"\d(?=[a-z])|[a-z](?=\d)");   
MatchCollection matchC;
matchC = reg.Matches(input);
int ii = 1;
foreach (Match element in matchC)//foreach match I will find the index of that match
{
    input = input.Insert(element.Index + ii, " * ");//since I' am inserting " * " ( 3 characters )
    ii += 3;                                        //I must increment index by 3
}
return input; //return modified input
.netを使用して同じ仕事をする方法についての私の質問MatchEvaluator?私は正規表現を初めて使用しますが、。に置き換えるのが適切かどうかわかりませんMatchEvaluator。これは私が書き込もうとしたコードです:
{
    Regex reg = new Regex(@"\d(?=[a-z])|[a-z](?=\d)");
    MatchEvaluator matchEval = new MatchEvaluator(ReplaceStar);
    input = reg.Replace(input, matchEval);
    return input;
}
public string ReplaceStar( Match match )
{
    //return What??
}