//密碼復雜度正則表達式 var regex = new Regex(@" (?=.*[0-9]) #必須包含數字 (?=.*[a-zA-Z]) #必須包含小寫或大寫字母 (?=([\x21-\x7e]+)[^a-zA-Z0-9]) #必須包含特殊符號 .{8,30} #至少8個字符,最多30個字符 ", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); //校驗密碼是否符合 bool pwdIsMatch = regex.IsMatch(user.USER_PASS);