string message = "Your purchase of $ 100.00 is awaiting for confirmation. Please use PIN 8967 to complete the transaction. Reference Number :1237689";
string output = Regex.Replace(message, @"[\d-]", "*");
Console.WriteLine("Message : " + message);
Console.WriteLine("Output : " + output);
Console.ReadLine();
我想只替换消息的PIN。但上面的消息从*字符替换所有数值。C#替换部分消息
使用表达式'(PIN)\ d +'和替换用1'$ ****'。 – Tushar