Let assume that I have some string: “Lorem ipsum dolor sit amet”
I need a list of all words with lenght more than 3. Can I do it with regular expressions?
e.g.
pattern = re.compile(r'some pattern')
result = pattern.search('Lorem ipsum dolor sit amet').groups()
result contains ‘Lorem’, ‘ipsum’, ‘dolor’ and ‘amet’.
EDITED:
The words I mean can only contains letters and numbers.
Take note that in Python 3, where all strings are Unicode, this will also find words that use non-ASCII letters:
In Python 2, you’d have to use