Simple regex with whitespaces

James Stroud jstroud at mbi.ucla.edu
Mon Sep 11 17:38:54 EDT 2006


Paul McGuire wrote:
> <mathieu.malaterre at gmail.com> wrote in message 
> news:1157945804.805624.32620 at p79g2000cwp.googlegroups.com...
> 
>>Hello,
>>
>> I cannot figure out a way to find a regular expression that would
>>match one and only one of these two strings:
[clip]
>>Any suggestion ? Thanks a bunch !
>>Mathieu
>>
> 
> A pyparsing approach is not as terse as regexp's, but it's not terribly long 
> either.

To second Paul's suggestion, usually, if the regex is not immediately 
obvious, its probably better to look into parsing modules, pyparsing 
being one of the most accessible modules (to me, anyways)--and well 
worth learning.

However, in complicated applications, regex is usually still fun and 
valuable as an intellectual exercise.

James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list