I have a string like this:
a = "\"java jobs in delhi\" delhi"
I want to replace delhi with "". But only delhi which lies outside the double-quotes. So, the output should look like this:
"\"java jobs in delhi\""
The string is a sample string.The substring not necessarily be "delhi".The substring to replace can occur anywhere in the input string. The order and number of quoted and unquoted parts in the string is not fixed
.replace() replaces both the delhi substrings. I can't use rstrip either as it wont necessarily appear at the end of the string. How can I do this?
"\"java jobs in pune\" pune"as well. So, I am basically looking for a generic solution."