Why no RE match of A AND B?

Paddy paddy3118 at tiscali.co.uk
Mon Mar 3 14:26:31 EST 2003


Paddy wrote:
> 
> 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. An arbitrary number of REs 
> can be separated by the "&" in this way. This can be used inside groups 
> as well. REs separated by "&" are tried in arbitrary order, the 
> beginning of the first matching branch up to the end of the last branch 
> that allows the complete pattern (all branches) to match is considered 
> the span of the match.
> 
> I envision it being used where a string is accepted at present if it 
> matches multiple REs.
> The REs could be rewritten as r"<RE#1>&<RE2>&<RE3>...".
> 
> The use of "&" could be supported by more efficient, (simultaneous?),  
> matching of all branches of the "&" construct - if such algorithms exist!
> 
>  Just an idea,
> 
>   Paddy.
> 

Thanks all, for your input so far.

Having thought of it, and seen the posts on if it is necessary or not, or needed or not; 
it seems a bit odd that we are left with one of the few places where the or 'operation' is 
defined, but the orthogonal and 'operation' is not ?!

Paddy.





More information about the Python-list mailing list