makeRegexpOptional = (charRegexp) => (
  stringToRegexp(
    charRegexp.toString()
      .replace(
        /.(\/)[gmiyus]{0,6}$/,
        (match) => match.replace('/', '?/'),
      ),
  )
)
Makes single-char regular express optional
@example
/\d/ -> /\d?/
@param {RegExp} charRegexp
@return {RegExp}