Why no RE match of A AND B?

Rene Pijlman reply.in at the.newsgroup
Sun Mar 2 17:44:05 EST 2003


Paddy:
>Just looking through the docs to confirm it and their seems to be no regular expression 
>construct that matches 'A and B' - an equivalent to the '|' character that matches A or B
>To paraphrase the documentation it could be documented as:
>
>   "&"
>A&B, where A and B can be arbitrary REs, creates a regular expression that will match both 
>A and B in any order. 

I take it this means: 

  match(r1&r2,s) <==> match(r1,s) and match(r2,s)

For example:

  r1 = aa?       (a or aa)
  r2 = aaa?      (aa or aaa)

implies that only "aa" matches r1&r2

But what's the purpose?

I assume (without a formal prove at this point) that r1&r2 can
always be reformulated as a simpler expression, BIMBW.

-- 
René Pijlman




More information about the Python-list mailing list