fork(3) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var strs = new List<string> { "PassWord", "PAssword", "PASSWord"};
  12. var n = 2;
  13. var pat = $@"^(?:[^A-Z]*[A-Z]){{{n}}}[^A-Z]*$";
  14. foreach (var s in strs) {
  15. Console.WriteLine("{0}: {1}", s, Regex.IsMatch(s, pat));
  16. }
  17. }
  18. }
Success #stdin #stdout 0.04s 134848KB
stdin
Standard input is empty
stdout
PassWord: True
PAssword: True
PASSWord: False