检查字符串是否同时包含数字和字母(至少) [英] check if string contains both number and letter (at least)
本文介绍了检查字符串是否同时包含数字和字母(至少)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查密码是否至少包含一个字母和一个数字.接受特殊字符但不是必需的...
I wish to check if a password contains at least one letter and a number. special characters are accepted but not required...
这将是一个简单的密码检查器.
That will be a simple password checker.
推荐答案
你可以使用先行断言来检查任何数字和任何字母的存在:
You can use lookahead assertions to check for existence of any digit and any letter as:
^(?=.*[a-zA-Z])(?=.*[0-9])
这篇关于检查字符串是否同时包含数字和字母(至少)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文