fork(11) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.IO;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var data = "I have this (123) 556-7890 phone number, followed with 123 556 7890, and (123) 556- 7890.";
  9. var res = Regex.Replace(data, @"\(?\d{3}\)?-? *\d{3}-? *-?\d{4}",
  10. x => Regex.Replace(x.Value, @"\d(?!\d{0,3}$)", "X"));
  11. Console.WriteLine(res);
  12. }
  13. }
Success #stdin #stdout 0.12s 24672KB
stdin
Standard input is empty
stdout
I have this (XXX) XXX-7890 phone number, followed with XXX XXX 7890, and (XXX) XXX- 7890.