I have the following sentence:
Dave put the rubbish in the {{ if dave_good }}bin{{ else }}street{{ endif }}.
I'm currently replacing variables in text strings by capturing [[ something ]]
and replacing the whole instance with a value (not a problem). But that's using python's re
library.
I was wondering if someone could show me how to:
- search for single instances of
{{ if dave_good }}
in the string - count forward from the
{{ if dave_good }}
to make sure there is a{{ endif }}
before the end of the string - if there is no
{{ else }}
then remove the tags, or the tags and their content, (at their location in the text) based on the boolean attribute ofdave_good
- if there is an
{{ else }}
- if
dave_good
isTRUE
then remove{{ if dav_good }}
and{{ else }}street{{ endif}}
- if
dave_good
isFALSE
then remove{{ endif }}
and{{ if dave_good }}bin{{ else }}
- if