Got this string and regex findall:
txt = """
dx d_2,222.22 ,,
dy h..{3,333.33} ,,
dz b#(1,111.11) ,, dx-ay relative 4,444.44 ,,
"""
for n in re.findall( r'([-\w]+){1}\W+([^,{2}]+)\s+,,\W+', txt ) :
axis, value = n
print "a:", axis
print "v:", value
In second (value) group I am trying to match anything except double commas, but it seems to catch only one ","
. I can got it in this example with simple (.*?)
but for certain reasons it got to be everything except ",,"
. Thank you.
EDIT: To see what I want to accomplish just use r'([-\w]+){1}\W+(.*?)\s+,,\W+'
instead. It will give you such output:
a: dx
v: d_2,222.22
a: dy
v: h..{3,333.33}
a: dz
v: b#(1,111.11)
a: dx-ay
v: relative 4,444.44
EDIT #2: Please, answer which did not include double comma exception is not what is needed. Is there a solution...should be. So patern is :
Any whitespace - word with possibly "-"
- than " "
- and everything to ",,"
except itself.