I have a string in Python:
Tt = "This is a <\"string\">string, It should be <\"changed\">changed to <\"a\">a nummber."
'This is a <"string">string, It should be <"changed">changed to <"a">a nummber.'
'This is a string, It should be changed to a nummber.'
Use regular expressions:
import re Tt = re.sub('<\".*?\">', '', Tt)
*. It makes the expression non-greedy,
so it tries to match so few symbols between
\"> as possible.
The Solution of James will work only in cases when the delimiting substrings
consist only from one character (
>). In this case it is possible to use negations like
[^>]. If you want to remove a substring delimited with character sequences (e.g. with
end), you should use non-greedy regular expressions (i.e.