Advertisement
Vassil_Iliev

Electronic message fixed

Mar 14th, 2022
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let string = gets()
  2. string = string.slice(0, -1);
  3. string = string.split(' ');
  4. let substringsWithoutLetters = [];
  5. let substringWithoutNumbers = []
  6. let lengthsArray = [];
  7.  
  8. for (let i = 0; i < string.length; i++) {
  9.     substringsWithoutLetters.push(string[i].replace(/[A-Za-z]/g, ' '));
  10.     substringWithoutNumbers.push(substringsWithoutLetters[i].replace(/\d/g, ' ').split(' '));
  11. }
  12.  
  13. let arr = [];
  14.  
  15. for (let i = 0; i < substringWithoutNumbers.length; i++) {
  16.     arr.push(...substringWithoutNumbers[i])
  17. }
  18.  
  19. for (let i = 0; i < arr.length; i++) {
  20.     lengthsArray.push(arr[i].length)
  21. }
  22. print(Math.max(...lengthsArray))
Advertisement
RAW Paste Data Copied
Advertisement