Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- // let regex = /(?<username>U\\$[A-Z][a-z][a-z]+U\\$)(?<password>P@\\$[a-z]{5,}[1-9]+P@\\$)/gm
- // let regex1 = /U\$[A-Z][a-z][a-z]+U\$P@\$[a-z]{5,}[1-9]+P@\$/gm
- // let regex2 = /U\$(?<username>[A-Z][a-z][a-z]+)U\$P@\$(?<password>[a-z]{5,}[1-9]+)P@\$/g;
- //
- // let number = Number(arr[0]);
- // let count = 0;
- //
- // for (let i = 1; i <= number; i++) {
- // let input = arr[i];
- // let match = regex2.exec(input);
- // if(match){
- // console.log('Registration was successful')
- // console.log(`Username: ${match.groups.username}, Password: ${match.groups.password}`)
- // count++
- // }else{
- // console.log('Invalid username or password')
- // }
- // }
- input.shift();
- let count = 0;
- for (const line of input) {
- let regex = /U\$(?<username>[A-Z][a-z][a-z]+)U\$P@\$(?<password>[a-z]{5,}[1-9]+)P@\$/g;
- let match = regex.exec(line);
- if(match){
- console.log(`Registration was successful`);
- console.log(`Username: ${match.groups.username}, Password: ${match.groups.password}`);
- count++;
- }else{
- console.log(`Invalid username or password`);
- }
- }
- console.log(`Successful registrations: ${count}`)
- }
Add Comment
Please, Sign In to add comment