Mutually exclusive regular expressions

Posted by CaptnCraig on Stack Overflow See other posts from Stack Overflow or by CaptnCraig
Published on 2010-06-03T16:40:41Z Indexed on 2010/06/03 16:44 UTC
Read the original article Hit count: 186

Filed under:
|

If I have a list of regular expressions, is there an easy way to determine that no two of them will both return a match for the same string?

That is, the list is valid if and only if for all strings a maximum of one item in the list will match the entire string.

It seems like this will be very hard (maybe impossible?) to prove definitively, but I can't seem to find any work on the subject.

The reason I ask is that I am working on a tokenizer that accepts regexes, and I would like to ensure only one token at a time can match the head of the input.

© Stack Overflow or respective owner

Related posts about regex

Related posts about mutual-exclusion