On 2009-11-20, mk <mrk...@gmail.com> wrote: > Hello, > > >>> r=re.compile(r'(?:[a-zA-Z]:)([\\/]\w+)+') > > >>> r.search(r'c:/tmp/spam/eggs').groups() > ('/eggs',) > > Obviously, I would like to capture all groups: > ('/tmp', '/spam', '/eggs')
You'll have to do something else, for example: >>> s = re.compile(r'(?:[a-zA-Z]:)') >>> n = re.compile(r'[\\/]\w+') >>> m = s.match('c:/tmp/spam/eggs') >>> n.findall(m.string[m.end():]) ['/tmp', '/spam', '/eggs'] -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list