So here's my problem:
I need to separate these punctuation items '], [, ?, !, (, ), ", ;, {, }' from whatever character they touch with a space. For example,
"Did he eat it (the bug)?" becomes: " Did he eat it ( the bug ) ? "
I can do something like:
re.search(r'[]?!()";{}', mytext)
But when the search finds a match, how do I reference the item that was matched so I can replace it with itself and a space? In pseudo-code:
replace(matched_punc, matched_punc + " ")
Or the space could come before if it's word-final, but I can hash that out later. Mostly I just need to figure out how to replace something with itself and a space.
Many thanks.