I need a python regular expression that will match all (non-empty) sequences of words in a string, assuming the word is an arbitrary non-empty sequence of non-white characters.
Something that will work as follows:
s = "ab cd efg"
re.findall(..., s)
# ['ab', 'cd', 'efg', 'ab cd', 'cd efg', 'ab cd efg']
The closest I got to this was using the module regex
, but still not what I want:
regex.findall(r"\b\S.+\b", s, overlapped=True)
Also, to be clear, I do not want to have 'ab efg'
there.
source
share