2 ms·
Your not missing anything, of course. They are also closed under difference, ie R0 - R1, which means accept all the strings accepted by R0 that aren't accepted
by rstuart4133 5y ago
Your not missing anything, of course.
They are also closed under difference, ie R0 - R1, which means accept all the strings accepted by R0 that aren't accepted by R1. Its very useful. For example, a variable is a token that isn't a keyword can be written succinctly as:
([a-z_][a-z_0-9]*) - (if|then|else|while|for)
Sadly, it was not part of the original re syntaxes so while common now it's not so well known, and the syntax varies wildly. For example, in VIM the above is:
[a-z_][a-z_0-9]*\(if\|then\|else\|while\|for\)\@<!
In Python and other pcre based matches like Perl it would be:
[a-z_[a-z_][a-z_0-9]*(?<!if|then|else|while|for)
They are also closed under conjunction, eg R0 & R1 matches strings that match both R0 and R1. Again it wasn't there in the first re packages and confusingly it (and difference) is called an "assertion" now. But there isn't a lot of difference between them and '|' - they are all just ways of composing regular expressions.