serdarshefketov

Electronic message

Dec 28th, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let message = gets();
  2. let regex = /\W|_/g;
  3. let count = 0;
  4. let temp = 0;
  5. for(let i = 0; i < message.length; i++){
  6.     if(message[i].match(regex) && message[i] != ' ' && message[i] != '.'){ // if its the specific char
  7.         temp++;
  8.     } else {
  9.         if(temp > count){
  10.             count = temp;
  11.             temp = 0;
  12.         } else {
  13.             temp = 0;
  14.         }
  15.     }
  16. }
  17. print(count);
Advertisement
Add Comment
Please, Sign In to add comment