Convert command pattern to regex