javascript - js searching for pattern doesnt work -


i used pattern make sure if there running same char 3 occurrence in php code , working when tried in javascript didn't work idea?

if (!(/(.)\\1{2}/.test(string))) {   console.log('there no running 3 chars occur in string'); } else{   console.log('there 3 running same char occur in string'); } 

the console give me "here no running 3 chars occur in string" although string "iii"

any idea?

you have escaped \ in pattern. trying match letter followed 2 \ characters. try updating pattern /(.)\1{2}/.

if (!(/(.)\1{2}/.test(string))){     console.log('there no running 3 chars occur in string'); } else {      console.log('there 3 running same char occur in string'); } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -