Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import re
# . matches any character
# * 0 or more of previous character
# + 1 or more of previous character
# ? 0 or 1 of previous character
sentence = '''The panda band in the stand is grand, but
the andromeda sand island is pretty bland. Their brand is
sandals, you understand, and the lowland androids stan an
downland.'''
pattern = re.compile(r'\s\wand')
for match in re.finditer(pattern, sentence):
print(match)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment