Help with regex needed

Chris Rebert clp2 at rebertia.com
Tue Apr 12 01:58:49 EDT 2011


On Mon, Apr 11, 2011 at 10:20 PM, Yuri Slobodyanyuk
<yuri.slobodyanyuk at gmail.com> wrote:
> Good day everyone,
> I am trying to make this pretty simple regex to work but got stuck,
> I'd appreciate your help .

"Some people, when confronted with a problem, think 'I know, I'll use
regular expressions.' Now they have two problems."

<snip>
> 1111111 Fri 4  8 2011
> 2323232 Fri 4 15 2011
> 4343434 Fri 4 22 2011
> 8522298 Fri 4 29 2011
> .........
> 5456678 Fri 10 28 2011
> 5633333 Fri 11  4 2011
> 4141411 Fri 11 11 2011
> 3324444 Fri 11 18 2011

There's no need to use regexes to parse such a simple file format.
Just use str.split() [without any arguments] on each line of the file,
and do the field equality checks yourself; your code will simpler.
Relevant docs: http://docs.python.org/library/stdtypes.html#str.split

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list