[英]Expression regular for password
I need the correct regular expression pattern, for checking input text in HTML matching this format:我需要正确的正则表达式模式,用于检查 HTML 中匹配此格式的输入文本:
Start with a capital letter以大写字母开头
End with the character $以字符 $ 结尾
Between the initial capital letter and the final dollar character there may be:在首字母大写和最后的美元字符之间可能有:
Example: B4rc3l0nA$, Fr4_nc3$, A$
示例:
B4rc3l0nA$, Fr4_nc3$, A$
I think I have to add anchors at the beginning and at the end, but I don't know how to join everything so that the complete regular expression remains.我想我必须在开头和结尾添加锚点,但我不知道如何加入所有内容,以便保留完整的正则表达式。
<input type="text" placeholder="Your password" pattern="^\[a-z]i\s-\s[0-9]{2}\([a-z]{1,3})$" required>
You can use this regular expression.您可以使用此正则表达式。
^[A-Z]\w+?\$$
^[AZ]
meaning start with capital character as first letter. ^[AZ]
表示以大写字母开头。\w+?
any letter or number or underscore\$$
dollar sign at the end. \$$
美元符号在末尾。 const checkPassword = (password) => { return /^[AZ]\w+?\$$/.test(password) } console.log(checkPassword("B4rc3l0nA$")) console.log(checkPassword("Fr4_nc3$")) console.log(checkPassword("Fr4_nc3")) console.log(checkPassword("fr4_nc3$")) console.log(checkPassword("Ab!!@@ÅÆØ}$"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.