Skip to content Skip to sidebar Skip to footer

Python Regular Expressions, How To Search For A Word Starting With Uppercase?

I'm relatively new to Python, and I just started learning regular expressions. I can't seem to figure how to find a word that starts with an uppercase. For example: text = '>:{a

Solution 1:

You can simply use re.findall with just the letter pattern (as the \w group will also match the _ character).

>>> re.findall('[A-Z][A-Za-z]*', text)
['Mitch', 'Pamela']

Post a Comment for "Python Regular Expressions, How To Search For A Word Starting With Uppercase?"