Making regex suck less

Carl Banks imbosol at vt.edu
Mon Sep 2 19:34:29 EDT 2002


John La Rooy wrote:
> Carl Banks wrote:
> 
>>>"anything,anything,anything,same_as_3rd,same_as_2nd,same_as_1st"
>>>or would you like to suggest something else?
>> 
>> 
>> How about:
>> 
>> pattern = Group(Any()) + Group(Any()) + Group(Any()) \
>>           + GroupRef(3) + GroupRef(2) + GroupRef(1)
>> 
> Err symantically that's exactly the same as the re and my suggestion
> only the syntax is different. It's still nothing like saying
> 
> pattern = "6 character palindrome"


Oh.  Well, methinks you don't give humans enough credit.  I'm a human,
and I can read the verbose regexp.  Of course, humans can read regular
expressions, too.  Maybe I don't give humans enough credit, either.
:-)

The point is, I was arguing for less-cryptic, more-verbose regular
expressions as a way to make complicated patterns more transparent.  I
certainly wasn't arguing for "6 character palindrome".


Sorry-for-the-confusion-ly y'rs


-- 
CARL BANKS
http://www.aerojockey.com



More information about the Python-list mailing list