Fixed regex bug in flag gen