Anchor edge of word
-
\b
-
\b beginning of word or end of word
import re
text = 'x a xyb x-c qwer_ ut!@y'
print(re.findall(r'.\b.', text))
print(re.findall(r'\b.', 'a b '))
print(re.findall(r'.\b', 'a b '))
Output:
['x ', 'a ', 'b ', 'x-', 'c ', '_ ', ' u', 't!', '@y']
['a', ' ', 'b', ' ']
['a', ' ', 'b']