Verify that passwords do not allow regular expressions with a continuous three-bit repetition

Source: Internet
Author: User
Tags repetition

var re =/(\w) * (\w) \2{2} (\w) */g;
JS validation password does not allow consecutive three-bit repetition of regular expressions

This regular means an arbitrary letter or number or underscore (captured as group 1) 0 times to several times followed by an arbitrary letter or number or underscore (captured as group 2) followed by "\2{2}" refers to the reverse capture Group 2 (that is, the content here is the same as the group 21 and appears 2 times, So it's equal to three repetitions) followed by an arbitrary letter or number or underscore 0 times to several times

<!DOCTYPE HTML><HTMLLang= "en"> <Head>  <MetaCharSet= "UTF-8">  <Metaname= "Generator"content= "editplus®">  <Metaname= "Author"content="">  <Metaname= "Keywords"content="">  <Metaname= "Description"content="">  <title>Document</title>  <Scriptsrc= "Http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></Script>  <Scriptlanguage= "JavaScript">  functionIspassword () {varStr= $("#testid"). Val (); varpatrn=/(.) *(.) \2{2} (.) */G; if(Patrn.exec (str)) {alert ('ture')            }Else{alert ('false'); }    }  </Script> </Head> <Body> <formMethod= "POST"class= "Form-horizontal"role= "form"Action=""ID= "MyForm">  <inputID= "TestID"name= "TestID"value= ' '>  <Buttononclick= "ispassword()"type= "button"ID= "Smsbtn"class= "Btn btn-success">Verify</Button></form> </Body></HTML>

Verify that passwords do not allow regular expressions with a continuous three-bit repetition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.