> but it can't pass this one: "(a c)b(c d) e" the above regex > gives out ['(a c)b(c', 'd)', 'e'], but the correct one should > be ['(a c)b(c d)', 'e']
Ah...the picture is becoming a little more clear: >>> r = re.compile(r'(?:\([^\)]*\)|\[[^\]]*\]|\S)+') >>> r.findall(s) ['(a c)b(c d)', 'e'] It also works on my original test data, and is a cleaner regexp than the original. The clearer the problem, the clearer the answer. :) -tkc -- http://mail.python.org/mailman/listinfo/python-list