You can make this `^[.@!]q(eueu)?\b(?P<command>l(length)?)?`. The `\b` is a word boundary, and the `.*` isn't required since we match from start to whatever gets matched.