Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function password(input) {
- let numberOfPasswords = input.shift();
- let regexPass = /^(.+)>(\d{3})\|([a-z]{3})\|([A-Z]{3})\|([^<>]{3})<\1$/;
- // регекс с именовани групи
- //let regexPass = /^(.+)>(?<first>\d{3})\|(?<second>[a-z]{3})\|(?<third>[A-Z]{3})\|(?<fourth>[^<>]{3})<\1$/;
- for (let i = 0; i < numberOfPasswords; i ++) {
- let matches = regexPass.exec(input[i]);
- if(matches){
- console.log(`Password: ${matches[2]}${matches[3]}${matches[4]}${matches[5]}`);
- // С именовани групи
- //console.log(`Password: ${matches.groups.first}${matches.groups.second}${matches.groups.third}${matches.groups.fourth}`);
- } else {
- console.log(`Try another password!`);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement