I was wondering if it\'s possible to use regex with python to capture a word, or a part of the word (if it\'s at the end of the string).
Eg:
target word - potato
Dont know how to match a regex in python, but the regex would be:
"\bp$|\bpo$|\bpot$|\bpota$|\bpotat$|\bpotato$"
This would match anything from p
to potato
if its the last word in the string, and also for example not something like "foopotato", if this is what you want.
The |
denotes an alternative, the \b
is a "word boundary", so it matches a position (not a character) between a word- and a non-word character. And the $
matches the end of the string (also a position).