Re: [Tutor] Making Regular Expressions readable

2010-03-08 Thread member thudfoo
On Mon, Mar 8, 2010 at 9:34 AM, spir wrote: > On Mon, 8 Mar 2010 16:12:35 + > Stephen Nelson-Smith wrote: > >> Hi, >> >> I've written this today: >> >> #!/usr/bin/env python >> import re >> >> pattern = >> r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, >> [0-9]{1,3}\.[0-9]{1,3}\.[

Re: [Tutor] Making Regular Expressions readable

2010-03-08 Thread spir
On Mon, 8 Mar 2010 16:12:35 + Stephen Nelson-Smith wrote: > Hi, > > I've written this today: > > #!/usr/bin/env python > import re > > pattern = > r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, > [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})*){1}) > (?P(\S*)) (?P(\S*)) > (?P(

[Tutor] Making Regular Expressions readable

2010-03-08 Thread Stephen Nelson-Smith
Hi, I've written this today: #!/usr/bin/env python import re pattern = r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})*){1}) (?P(\S*)) (?P(\S*)) (?P(\[[^\]]+\])) (?P(\"([^"\\]*(?:\\.[^"\\]*)*)\")?) (?P(\S*)) (?P(\S*)) (?P(\"([^"\\]*(?:\\