I have a string like this:
str1='x[cm],z,y[km]'
I want to find the units available in the above variable.
If I use re.findall(r"\[([A-Za-z0-9_/*^\\(\\)-\.]+)\]", str1)
then it gives ['cm', 'km'], but I want the output to be ['cm', '', 'km'] since z has no unit associated. How can I achieve this?
Similaly for input string T(x[g],y,z[m])[kg] the output should be ['g','','m','kg']