private static string VisitRegexOptions(MethodCallExpression m, RegexOptions options) { RegexOptions[] allowedOptions = new RegexOptions[] { RegexOptions.IgnoreCase, RegexOptions.Multiline, RegexOptions.None }; foreach (RegexOptions Type in Enum.GetValues(typeof(RegexOptions))) { if ((options & Type) == Type && !allowedOptions.Contains(Type)) throw new NotSupportedException(string.Format("Only the RegexOptions.Ignore and RegexOptions.Multiline options are supported.", m.Method.Name)); } var jsoptions = "g"; if ((options & RegexOptions.IgnoreCase) == RegexOptions.IgnoreCase) jsoptions += "i"; if ((options & RegexOptions.Multiline) == RegexOptions.Multiline) jsoptions += "m"; return jsoptions; }