I want to exclude the following: Anything starting with a curly brace, followed by the word color. After color there can be anything. Once I see the closing curly brace, that entire chunk needs to be eliminated. See below for the bolded stuff for an example. This is my expression so far.
^(?!.*({color})).*
What am I doing wrong? Thank you.
('|Activity|Planned Dates|Actual Dates|Status|\r\n'
'|Dev Cut Off|06/03/22\xa0|06/03/22|Complete|\r\n'
'|AOS Integration|06/10/22|06/10/22|Complete|\r\n'
'|**{color:#de350b}**QA Deploy{color}|{color:#de350b}06/14/22\xa0'
'{color}|{color:#de350b}06/16/22{color}|\r\n'
)
CodePudding user response:
So use
text = re.sub(r'\{color[^{}]*}', '', text)
See regex proof.
NODE EXPLANATION
--------------------------------------------------------------------------------
\{ '{'
--------------------------------------------------------------------------------
color 'color'
--------------------------------------------------------------------------------
[^{}]* zero or more characters different from curly braces
--------------------------------------------------------------------------------
} '}'