Any time I want to replace a piece of text that is part of a larger piece of text, I always have to do something like:
\"(?Psome_pattern)(?P<
Look in the Python re documentation for lookaheads (?=...) and lookbehinds (?<=...) -- I'm pretty sure they're what you want. They match strings, but do not "consume" the bits of the strings they match.
(?=...)
(?<=...)