I want to replace part of a string in Python. In particular, I want to get rid of the structure "Hello[hi, ... ,bye]"
, where the dots represent any length of characters.
I have found that in How to use string.replace() in python 3.x it is explained how to use replace, but I can not figure out how to match the pattern "Hello[hi, ... ,bye]" with an arbitrary piece of string in place of '...'
Example 1:
text= "Hello.hi[. Hello[hi, my name is alice ,bye] ,bye]"
I want: result= "Hello.hi[., 123 my name is alice 456 ,bye]"
But I want the same pattern also to work for example 2:
text= "Hello.hi[., Hello[hi, have a good day ,bye] ,bye]"
I want: result= "Hello.hi[., 123 have a good day 456 ,bye]"
Any suggestions? Thanks.