Skip to content

Instantly share code, notes, and snippets.

@skysan87
Last active June 4, 2019 14:55
Show Gist options
  • Save skysan87/527b213fc083df15913ea4e4bcfe3033 to your computer and use it in GitHub Desktop.
Save skysan87/527b213fc083df15913ea4e4bcfe3033 to your computer and use it in GitHub Desktop.
[C#] 正規表現サンプル
private bool isMatch(string input)
{
// 英字小文字、大文字、数字を1つずつ含み、8文字以上(記号は含まない)
var pattern = @"^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,}$";
// NOTE:記号を含む場合、ASCII表記の方が楽かも[\x21-\x7e]
return Regex.IsMatch(input, pattern);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment