My intention is to select only those packages whose name do not contain adlib or ads. But if i add *adlib* and *ads* it selects all packages containing the substring adlib and ads. So i need a regular expression to select all packages that do not contain substring adlib and ads.
Asked
Active
Viewed 62 times
1
Sarvottamananda
- 4,877
- 1
- 14
- 19
Jose Kj
- 113
- 3
1 Answers
2
Let $[$^$x]$, $[$^$xy]$ be short cuts for $\Sigma - \{x\}$, $\Sigma - \{x, y\}$ etc., i.e., $[$^$a]$ will be regular expression: $(b+c+d+\dots)$.
Then the regular expresseion for words not containing ads or adlib would be
$[$^$a]^*(a[$^$d][$^$a]^*+ad([$^$sl][$^$a]^* $ $+ adl[$^$i][$^$a]^* + adli[$^$b][$^$a]^*)^* (\epsilon + a +ad + adl + adli)$.
Basically we wait for an $a$ and then check it is not followed by the disallowed combinations.
Since regular expressions have built in operators for union, kleene and concatenation only, we will always have trouble with intersection, complement and minus operations. Basically the operation you want in your question is the complement.
Sarvottamananda
- 4,877
- 1
- 14
- 19
