Reduce duplication in compile_flag_regexp().