Code Lab

Letters only

EasyStrings5 min

Write a function onlyLetters(text) that keeps only the Latin letters a to z and A to Z in a string. Digits, spaces, punctuation and letters of other alphabets are removed. Letters keep their case.

Examples

onlyLetters('a1b$c d!')

Returns 'abcd'

onlyLetters('Test123Case')

Returns 'TestCase'

onlyLetters('Привет, QA!')

Returns 'QA'

Cyrillic letters go too.

Asked at Paytm · Source

Loading the editor...
  1. InputonlyLetters('a1b$c d!')
    Expected'abcd'
  2. InputonlyLetters('Test123Case')
    Expected'TestCase'
  3. InputonlyLetters('Привет, QA!')
    Expected'QA'

Hidden tests run on Submit.