简体   繁体   中英

regex in JS for no letters and identical chars

got a problem with two regular expressions in javascript. I need one expression that matches, when my string contains no a-zA-Z . Like 12345 . Stuff like \\W\\S or [^a-zA-Z] is not working, cause it matches 123a etc. Getting crazy with that one.

The other expression is the matching of two identical letters like the 'ss' in password. (.)\\1 is not working with javascript. In c# no problem. What am I doing wrong with that one?

Made a section in my web.config which defines password-rules and in my code (c#, asp.net 3.5) I am reading the rules to create javascript for the client.

Thanks for help

您还需要像这样使用开始和结束锚点,以确保您的完整字符串不与任何字母匹配:

/^[^a-zA-Z]+$/

以下正则表达式可以匹配连续的相同字符-

(\w)\1{1,}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM