How can I extract with python all strings starting with 'a['
and ending with ']'
?
for example
str= "a[0]*x**3+a[13]"
result : a[0], a[13]
thanks
How can I extract with python all strings starting with 'a['
and ending with ']'
?
for example
str= "a[0]*x**3+a[13]"
result : a[0], a[13]
thanks
We can use re.findall
here:
inp = "a[0]*x**3+a[13]"
matches = re.findall(r'\ba\[.*?\]', inp)
print(matches) # ['a[0]', 'a[13]']