An warware: kalmar sirri regex

Babban matsalar da ke tattare da kalmar sirri regex ita ce ana iya yin kutse cikin sauki. Mai hacker zai iya amfani da regex don nemo kalmomin shiga sannan ya yi amfani da waษ—ancan kalmomin shiga don samun damar asusu.

var password = "abc123";
var regex = /^(?=.*d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/;
if(regex.test(password)) {
  console.log("Password is valid");
} else {
  console.log("Password is invalid");
}

Layin farko ya ฦ™irฦ™iri maษ“alli da ake kira โ€œPasswordโ€ kuma ya sanya darajar โ€œabc123โ€ gare shi. Layi na biyu ya ฦ™irฦ™iri madaidaicin da ake kira "regex" kuma ya sanya ma'anar magana akai-akai. Wannan magana ta yau da kullun tana bincika idan kalmar sirri ta ฦ™unshi aฦ™alla lamba ษ—aya, ฦ™aramin harafi ษ—aya, da babban harafi ษ—aya. Layi na uku yana bincika idan kalmar sirrin da mai amfani ya shigar (an adana shi a cikin maballin โ€œPasswordโ€) yayi daidai da kalmar yau da kullun da aka adana a cikin m โ€œregexโ€. Idan ya yi, sa'an nan saฦ™on "Passsword yana aiki" yana nunawa akan na'urar bidiyo. Idan ba haka ba, to ana nuna saฦ™on โ€œPassword is invalidโ€ a kan naโ€™urar bidiyo.

regex

Regex babban ษ—akin karatu ne mai sarrafa rubutu don JavaScript. Yana ba ku damar daidaita alamu a cikin rubutu, kuma ana iya amfani da su don dalilai daban-daban, kamar inganci ko bincike.

JavaScript da kalmomin shiga

ฦŠaya daga cikin hanyoyin da aka fi sani don adana kalmomin shiga cikin JavaScript shine amfani da mai sarrafa kalmar sirri. Mai sarrafa kalmar sirri yana adana kalmomin shiga a cikin amintacciyar hanya kuma zai iya taimaka maka tuna kalmomin shiga da yawa.

Shafi posts:

Leave a Comment