By default, anything that doesn't match any of the flex rules is printed. So your rules match the [whatever]
lines and print whatever
(removing the [
and ]
), while the default rule matches everything else (printing it).
Add a rule like:
.|\n { /* ignoring all other unmatched text */ }
to the end of your rules if you want to ignore everything else, rather than printing it.