Fix regex flag bug

Fix the js error when you check some flag