Skip to content

Instantly share code, notes, and snippets.

@sagorbrur
Created October 31, 2019 08:47
Show Gist options
  • Save sagorbrur/d7f0fc3e9a98d87c2be513e37bfefa64 to your computer and use it in GitHub Desktop.
Save sagorbrur/d7f0fc3e9a98d87c2be513e37bfefa64 to your computer and use it in GitHub Desktop.
import re
TEXTO = sys.argv[1]
my_regex = r"\b(?=\w)" + re.escape(TEXTO) + r"\b(?!\w)"
result = re.search(my_regex, subject, re.IGNORECASE)
print(result)
# ref
# https://stackoverflow.com/questions/6930982/how-to-use-a-variable-inside-a-regular-expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment