function isValidRegexForEcmaVersion(pattern, flags) {
			const validator = new RegExpValidator({
				ecmaVersion: regexppEcmaVersion,
			});

			try {
				validator.validatePattern(pattern, 0, pattern.length, {
					unicode: flags ? flags.includes("u") : false,
					unicodeSets: flags ? flags.includes("v") : false,
				});
				if (flags) {
					validator.validateFlags(flags);
				}
				return true;
			} catch {
				return false;
			}
		}
Checks whether the given regex and flags are valid for the ecma version or not.
@param {string} pattern The regex pattern to check.
@param {string | undefined} flags The regex flags to check.
@returns {boolean} True if the given regex pattern and flags are valid for the ecma version.