fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace RegExApplication
  5. {
  6. public class Program
  7. {
  8. public static void Main(string[] args)
  9. {
  10. string input = "-user 'username' -locale 'us' -pwd 'realpwd' -time 'pst' ";
  11. string pattern = "(-pwd +)\'(?:.*?)\'";
  12. Regex rgx = new Regex(pattern);
  13. string result = rgx.Replace(input, "$1\'****\'");
  14.  
  15. Console.WriteLine("Original String: {0}", input);
  16. Console.WriteLine("Replacement String: {0}", result);
  17. Console.ReadKey();
  18. }
  19. }
  20. }
Success #stdin #stdout 0.11s 24608KB
stdin
Standard input is empty
stdout
Original String: -user 'username' -locale 'us' -pwd 'realpwd' -time 'pst' 
Replacement String: -user 'username' -locale 'us' -pwd '****' -time 'pst'