fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string[] strings = { "File name without 3 digit end.jpg",
  9. "username1@example.com",
  10. "username@example.com",
  11. "username1@example@example.com",
  12. "username1@",
  13. "test",
  14. };
  15.  
  16. String pattern = @"\G([^\s@])[^\s@](?=[^\s@]*@[^\s@]+(?!\S))";
  17. Regex regex = new Regex(pattern);
  18. string substitution = @"$1*";
  19. foreach(string str in strings)
  20. {
  21. Console.WriteLine(regex.Replace(str, substitution));
  22. }
  23. }
  24. }
Success #stdin #stdout 0.05s 21016KB
stdin
Standard input is empty
stdout
File name without 3 digit end.jpg
u*e*n*m*1@example.com
u*e*n*m*@example.com
username1@example@example.com
username1@
test