-4

Username : at least 5 letters and all lowercase letters Password : is a combination of 2-digit numbers followed by the symbol "@" or the symbol "&" and followed by 4 uppercase letters

Example : Username : meatball / jungernaut Password : 21@YOUR / 74&GOOD

IAM TRY

var slt = "gordonbam"
var sltk = "12@BANA"
var username =  /[1-5][A-Z]/g;
var password = /[1-2](@|&)\w[1-4][A-Z]/g;

var result1 = slt.match(username);
var result2 = sltk.match(password);

console.log(result1);
console.log(result2);

2 Answers2

0

Maybe,

^[0-9]{2}[@&][A-Z]{4}$

and

^[a-z]{5,}$

might work OK for pass and username.


If you wish to simplify/modify/explore the expression, it's been explained on the top right panel of regex101.com. If you'd like, you can also watch in this link, how it would match against some sample inputs.


RegEx Circuit

jex.im visualizes regular expressions:

enter image description here

const regex = /^\d{2}[@&][A-Z]{4}$/gm;
const str = `21@YOUR
74&GOOD
74&aaaa
74&AAAz`;
let m;

while ((m = regex.exec(str)) !== null) {
    // This is necessary to avoid infinite loops with zero-width matches
    if (m.index === regex.lastIndex) {
        regex.lastIndex++;
    }
    
    // The result can be accessed through the `m`-variable.
    m.forEach((match, groupIndex) => {
        console.log(`Found match, group ${groupIndex}: ${match}`);
    });
}
Emma
  • 27,428
  • 11
  • 44
  • 69
  • function password(pw) { fpassword = /[0-9]{3}[*][a-z]{3}$/; console.log(fpassword.test(pw)); } password("111*sss"); password("123*try"); – kui beatbox Nov 16 '19 at 04:40
0

for Username:

^([a-z]*[a-z]){5}[a-z]*$

for Password:

^[0-9]{2}[@][A-Z]{4}$

try this and if there is any problem then comment me

Milan Tejani
  • 372
  • 5
  • 21