Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created January 3, 2021 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/6f8fa6e05b189f367cef34b186a5cf1e to your computer and use it in GitHub Desktop.
Save JeffersGlass/6f8fa6e05b189f367cef34b186a5cf1e to your computer and use it in GitHub Desktop.
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