I was doing some challenges in python when I stumbled upon a hitch I couldn’t find how to solve:
how can I specify a certain character when it’s next to another character without matching the latest ?
Exemple, let’s say I wan’t to split the string
"I don't know what 'python' means " into seperate words :
I want my regex to match the quote inside the word
don't since it’s part of the word, but I wouldn’t want to match the quote around
python since those are meta-characters, not part of a word.
My first guess would be to only match a quotation mark when it’s surronded by alpha characters, but I wouldn’t know how to do that without matching the character that surronds the quote :
for exemple :
r"\w'\w" would match
r"[\w'\w]" would match any quotation mark or alpha characters.
Any help is appreciated, thanks a lot for readig !