I'm new to Python and I want to remove and replace the ({ / / }) with space, the sample below
The original sentence:
NULL ({ / / }) Regina ({ 4 p1 p2 / / }) Shueller ({ 5 p1 p2 / / }) works ({ / / }) for ({ / / }) Italy ({ 14 / / }) 's ({ 15 / / }) La ({ 16 / / }) Repubblica ({ 17 / / }) newspaper ({ 18 / / }) . ({ 38 / / })
Transform to this:
Regina Shueller works for Italy 's La Repubblica newspaper.
I've tried this code but that was not what I expected
Sentence = re.sub(r'[({ / / })]',' ', sentence)
r'\s*(?:\(\{[^/]*/\s*/\s*}\)|NULL)\s*'(to be replaced with space). But the space between the last word and the.cannot be removed like this. And the value must be trimmed from spaces.(?1)). Or withrethis pattern:\({[^}]*}\)|NULL|\s+(?!\w)and trim leading space.