What is best pure Python implementation to check if a string contains ANY letters from the alphabet?
JavaScript
x
3
1
string_1 = "(555).555-5555"
2
string_2 = "(555) 555 - 5555 ext. 5555
3
Where string_1
would return False
for having no letters of the alphabet in it and string_2
would return True
for having letter.
Advertisement
Answer
Regex should be a fast approach:
JavaScript
1
2
1
re.search('[a-zA-Z]', the_string)
2