Q:

Check if string contains characters other than alphabetical character

I want a function to return TRUE if a string contains only letters, and FALSE otherwise.
I had a hard time finding a solution for this problem using R even though there are many answer pages for other languages.

A:

We can use grep.  We match letters [A-Za-z] from the start (^) to the end $ of the string.
grepl('^[A-Za-z]+$', str1)
#[1]  TRUE FALSE

data
str1 <- c('Azda', 'A123Zda')

