RE Question

Yoav yoav_artzi at il.vio.com
Thu Aug 18 10:21:20 EDT 2005


I don't understand why the two REs produce a different result. I read 
the RE guide but still I can't seem to figure it out.

 >>> t
'echo user=name password=pass path="/ret files"\r\n'
 >>> re.findall(r'(?<=\s)[^=]+=((?:".*")|(?:\S*))(?=\s)', t)
['name', 'pass', '"/ret files"']
 >>> re.findall(r'(?<=\s)[^=]+=((".*")|(\S*))(?=\s)', t)
[('name', '', 'name'), ('pass', '', 'pass'), ('"/ret files"', '"/ret 
files"', '')]


Also, does '|' char (meaning or) produces a pair for each section. I 
don't understand how it works. Can someone please direct me to a place 
which will explain it?

Thanks.



More information about the Python-list mailing list