I have these three strings:
letters <- "abc"
numbers <- "123"
mix <- "b1dd"
How can I check which one of these strings contains LETTERS ONLY or NUMBERS ONLY (in R)?
letters
should only be TRUE in the LETTERS ONLY check
numbers
should only be TRUE in the NUMBERS ONLY check
mix
should be FALSE in every situation
I tried several approaches now but none of them really worked for me :(
For example if I use
grepl("[A-Za-z]", letters)
It works well for letters
, but it would also works for mix
, what I don't want.
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…