That's why you need compiler-compiler for pattern-matching:

abc2 := abc | abc2 abc
abc := ab c
ab := a | b;
a := 'a';
b := 'b';
c := 'c';

You need one Compiler to compile:

((a|b)*c)*

And searching for the expression is a compiler too