function appendFlagToRegExp(pattern, appendFlag) {
  const regularExpressionFlags = getRegExpFlags(pattern);
  if (!includes(regularExpressionFlags, appendFlag)) {
    return new RegExp(pattern.source, regularExpressionFlags + appendFlag);
  }
  return pattern;
}
Append flag to a regular expression.

@ignore
@param {RegExp} pattern The pattern to coerce.
@param {string} appendFlag The flag to append to regular expression.
@return {RegExp} The regular expression with added flag.