Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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']