How can I match a pattern and extract in between particular expressions of a string ? here in between ${ and }
string = '''${data1}, ${data2}, ${data3}... ''' so my question is how can I extract `data1,data2 .... in the entire string?
How can I match a pattern and extract in between particular expressions of a string ? here in between ${ and }
string = '''${data1}, ${data2}, ${data3}... ''' so my question is how can I extract `data1,data2 .... in the entire string?
Try this one with the help of regex.
In [105]: import re In [106]: m = re.findall('\${(.+?)}', string) In [107]: m Out[107]: ['data1', 'data2', 'data3'] re.sub for replacing.