fix regexp to match nx at the beginning and at the end of the flags
fix trailing space