AreWe

Registration

Aug 7th, 2020
1,600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. registration = (input) => {
  2.     let N = Number(input.shift()),
  3.         successfulCount = 0;
  4.     for(let i = 0; i < N; i++) {
  5.         let registration = input.shift();
  6.         let match = registration.match(/U\$(?<username>[A-Z][a-z]{2,})U\$P@\$(?<password>[A-Za-z]{5,}[0-9]+)P@\$/);
  7.         if(match !== null) {
  8.             console.log(`Registration was successful\nUsername: ${match.groups.username}, Password: ${match.groups.password}`);
  9.             successfulCount++;
  10.         } else {
  11.             console.log('Invalid username or password');
  12.         }
  13.     }
  14.     console.log(`Successful registrations: ${successfulCount}`);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment