/// <summary>
        /// Converts regex in string to RegExOptions, valid flags are "i", "m"
        /// Throws RegularExpressionInvalidOptionsException if there are any invalid options
        /// </summary>
        /// <param name="regexOptions"></param>
        /// <returns></returns>
        public static RegexOptions ConvertToRegexOptions(String regexOptions)
        {
            RegexOptions result;

            if (TryConvertToRegexOptions(regexOptions, out result))
            {
                return(result);
            }

            throw new RegularExpressionInvalidOptionsException(PipelineStrings.InvalidRegexOptions(regexOptions, String.Join(",", WellKnownRegexOptions.All)));
        }
        private static Boolean IsSafeMatch(
            String value,
            Func <String, Match> getSafeMatch)
        {
            Boolean result = true;

            try
            {
                var match = getSafeMatch(value);
                result = match.Success;
            }
            catch (Exception ex) when(ex is RegexMatchTimeoutException || ex is ArgumentException)
            {
                throw new RegularExpressionValidationFailureException(PipelineStrings.RegexFailed(value, ex.Message), ex);
            }

            return(result);
        }