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