internal RegExpMatch(ArrayPrototype parent, Regex regex, Match match, string input) : base(parent, typeof(RegExpMatch)) { this.hydrated = false; this.regex = regex; this.matches = null; this.match = match; base.SetMemberValue("input", input); base.SetMemberValue("index", match.Index); base.SetMemberValue("lastIndex", (match.Length == 0) ? (match.Index + 1) : (match.Index + match.Length)); string[] groupNames = regex.GetGroupNames(); int num = 0; for (int i = 1; i < groupNames.Length; i++) { string name = groupNames[i]; int num3 = regex.GroupNumberFromName(name); if (name.Equals(num3.ToString(CultureInfo.InvariantCulture))) { if (num3 > num) { num = num3; } } else { Group group = match.Groups[name]; base.SetMemberValue(name, group.Success ? group.ToString() : null); } } this.length = num + 1; }
public Parser () { _Regex = new Regex( @"((?'number'(-?)[0-9]+(\.[0-9]+)?)|(?'identifier'[_A-Za-z][A-Za-z0-9_]*)|(?'operator'<=|>=|!=|[\-+/*&|^!><=.%?:@])|(?'paren'[(){}]))|(?'comma',)", RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture ); _Group_Number = _Regex.GroupNumberFromName("number"); _Group_Identifier = _Regex.GroupNumberFromName("identifier"); _Group_Operator = _Regex.GroupNumberFromName("operator"); _Group_Paren = _Regex.GroupNumberFromName("paren"); _Group_Comma = _Regex.GroupNumberFromName("comma"); }
internal ReplaceUsingFunction(Regex regex, ScriptFunction function, string source) { this.function = function; this.cArgs = function.GetNumberOfFormalParameters(); bool flag = (function is Closure) && ((Closure) function).func.hasArgumentsObject; this.groupNumbers = null; this.source = source; if ((this.cArgs > 1) || flag) { string[] groupNames = regex.GetGroupNames(); int num = groupNames.Length - 1; if (flag) { this.cArgs = num + 3; } if (num > 0) { if (num > (this.cArgs - 1)) { num = this.cArgs - 1; } this.groupNumbers = new int[num]; for (int i = 0; i < num; i++) { this.groupNumbers[i] = regex.GroupNumberFromName(groupNames[i + 1]); } } } }
/// <summary> /// This method parses a friendly Derived Columns expression entered by the user into a Lineage-ID based /// expression which is required by SSIS, using a regular-expression based parser. /// Additionally, it will set the Input Column Usage for any columns found in the expression. /// </summary> /// <param name="expression">Expression to be parsed.</param> /// <param name="transformation">Transformation to use for evaluating the lineage IDs</param> /// <param name="vi">Transformation Virtual Input used to search for input columns.</param> /// <param name="inputColumnUsageType">DTSUsageType for columns mapped in this expression.</param> /// <returns>Expression struct with the pre-processed and post-processed expression.</returns> public static Expression ExpressionCleanerAndInputMapBuilder(string expression, Transformation transformation, IDTSVirtualInput100 vi, DTSUsageType inputColumnUsageType) { Expression exp = new Expression(); exp.OriginalExpression = expression; exp.ProcessedExpression = expression; exp.FriendlyExpression = expression; exp.ContainsId = false; foreach (IDTSVirtualInputColumn100 vcol in vi.VirtualInputColumnCollection) { string regexString = String.Format(CultureInfo.CurrentCulture, "(\"(?:[^\"]|(?<=\\\\)\")*\")|(?<vCol>(?<!@\\[?|:)\\[?\\b{0}\\b\\]?)", Regex.Escape(vcol.Name)); var regex = new Regex(regexString, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); int groupNumber = regex.GroupNumberFromName("vCol"); var processedEme = new ExpressionMatchEvaluatorStruct(groupNumber, "#" + vcol.LineageID, transformation, vi, inputColumnUsageType, vcol); var friendlyEme = new ExpressionMatchEvaluatorStruct(groupNumber, vcol.Name, null, null, DTSUsageType.UT_IGNORED, null); exp.ProcessedExpression = regex.Replace(exp.ProcessedExpression, new MatchEvaluator(processedEme.EvaluateMatch)); exp.FriendlyExpression = regex.Replace(exp.FriendlyExpression, new MatchEvaluator(friendlyEme.EvaluateMatch)); } if (exp.ProcessedExpression != exp.OriginalExpression) { exp.ContainsId = true; } return exp; }
public void NameLookupMatch() { Regex regTime = new Regex( @"(?<hour>[0-9]{1,2})([\:](?<minute>[0-9]{1,2})){0,1}([\:](?<second>[0-9]{1,2})){0,1}\s*(?<ampm>(?i:(am|pm)){0,1})"); Match mTime = regTime.Match("12:00 pm"); Assert.AreEqual(4, regTime.GroupNumberFromName("hour"), "#A1"); Assert.AreEqual(5, regTime.GroupNumberFromName("minute"), "#A1"); Assert.AreEqual(6, regTime.GroupNumberFromName("second"), "#A1"); Assert.AreEqual(7, regTime.GroupNumberFromName("ampm"), "#A1"); Assert.AreEqual("12", mTime.Groups["hour"].Value, "#B1"); Assert.AreEqual("00", mTime.Groups["minute"].Value, "#B2"); Assert.AreEqual("", mTime.Groups["second"].Value, "#B3"); Assert.AreEqual("pm", mTime.Groups["ampm"].Value, "#B4"); }
static int GroupNumberFromName(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); System.Text.RegularExpressions.Regex obj = (System.Text.RegularExpressions.Regex)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.Text.RegularExpressions.Regex"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); int o = obj.GroupNumberFromName(arg0); LuaScriptMgr.Push(L, o); return(1); }
static public int GroupNumberFromName(IntPtr l) { try { System.Text.RegularExpressions.Regex self = (System.Text.RegularExpressions.Regex)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GroupNumberFromName(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
internal ReplaceUsingFunction(Regex regex, ScriptFunction function, String source) { this.function = function; this.cArgs = function.GetNumberOfFormalParameters(); bool hasArgumentsObject = (function is Closure) && ((Closure)function).func.hasArgumentsObject; this.groupNumbers = null; this.source = source; if (this.cArgs > 1 || hasArgumentsObject) { String[] groupNames = regex.GetGroupNames(); int cGroupNumbers = groupNames.Length - 1; if (hasArgumentsObject) this.cArgs = cGroupNumbers+3; if (cGroupNumbers > 0) { if (cGroupNumbers > this.cArgs - 1) cGroupNumbers = this.cArgs - 1; this.groupNumbers = new int[cGroupNumbers]; for (int i = 0; i < cGroupNumbers; i++) this.groupNumbers[i] = regex.GroupNumberFromName(groupNames[i+1]); } } }
internal static string Reformat (Regex regex, string replacement) { replacement = JavaUtils.ReplaceAll (replacement, BACKSLASH_PATTERN, JAVA_BACKSLASH); replacement = JavaUtils.ReplaceAll (replacement, DOUBLE_DOLLAR_PATTERN, JAVA_DOLLAR); Pattern p = Pattern.compile (SINGLE_DOLLAR_PATTERN); Matcher m = p.matcher ((CharSequence) (object) replacement); StringBuffer sb = new StringBuffer (); while (m.find ()) { if (m.start (1) >= 0) { int groupNumber = regex.GroupNumberFromName (m.group (1)); if (groupNumber >= 0) { m.appendReplacement (sb, @"\$" + regex.GetJavaNumberByNetNumber (groupNumber)); continue; } if (int.TryParse (m.group (1), out groupNumber) && groupNumber <= regex.GroupCount) { m.appendReplacement (sb, @"\$" + regex.GetJavaNumberByNetNumber (groupNumber)); continue; } m.appendReplacement (sb, JAVA_DOLLAR + "{" + m.group (1) + "}"); continue; } if (m.start (2) >= 0) { int netGroupNumber = int.Parse (m.group (2)); if (netGroupNumber > regex.GroupCount) { m.appendReplacement (sb, JAVA_DOLLAR + netGroupNumber); continue; } m.appendReplacement (sb, @"\$" + regex.GetJavaNumberByNetNumber (netGroupNumber)); continue; } m.appendReplacement (sb, JAVA_DOLLAR); } m.appendTail (sb); return sb.ToString (); }
public static void Run(string path, int field) { Regex regex = new Regex(@" \G(^|,) "" (?<field> (?> [^""]*) (?> """" [^""]* )* ) "" | (?<field> [^"",]* )", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace); int fieldGroupIndex = regex.GroupNumberFromName("field"); using (StreamReader csv = new StreamReader(path)) { string s; if (field == -1) { while ((s = csv.ReadLine()) != null) { MatchCollection m = regex.Matches(s); for (int i = 0; i < m.Count; i += 2) s = m[i].Groups[fieldGroupIndex].Value; } } else { while ((s = csv.ReadLine()) != null) { MatchCollection m = regex.Matches(s); s = m[field << 1].Groups[fieldGroupIndex].Value; } } } }
internal RegExpMatch(ArrayPrototype parent, Regex regex, Match match, String input) : base(parent, typeof(RegExpMatch)){ this.hydrated = false; this.regex = regex; this.matches = null; this.match = match; base.SetMemberValue("input", input); base.SetMemberValue("index", match.Index); base.SetMemberValue("lastIndex", match.Length == 0 ? match.Index + 1 : match.Index + match.Length); String[] groupNames = regex.GetGroupNames(); int maxGroupNumber = 0; for (int i = 1; i < groupNames.Length; i++) { String groupName = groupNames[i]; int groupNumber = regex.GroupNumberFromName(groupName); if (groupName.Equals(groupNumber.ToString(CultureInfo.InvariantCulture))){ if (groupNumber > maxGroupNumber) maxGroupNumber = groupNumber; }else{ Group group = match.Groups[groupName]; base.SetMemberValue(groupName, group.Success ? group.ToString() : null); } } this.length = maxGroupNumber+1; }
public static void ReadAll_Regex(DelimitedRecordReaderBenchmarkArguments args) { // regex from Jeffrey Friedl's Mastering Regular Expressions 2nd edition, p. 271 // does NOT handle trimming and multiline fields Regex regex = new Regex(@" \G(^|,) ""(?<field> (?> [^""]*) (?> """" [^""]* )* )"" | (?<field> [^"",]* )", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace); int fieldGroupIndex = regex.GroupNumberFromName("field"); using (var sr = new StreamReader(args.Path, args.Encoding, true, args.BufferSize)) { string s; if (args.FieldIndex < 0) { while ((s = sr.ReadLine()) != null) { MatchCollection mc = regex.Matches(s); for (int i = 0; i < mc.Count; i += 2) s = mc[i].Groups[fieldGroupIndex].Value; } } else { while ((s = sr.ReadLine()) != null) { MatchCollection mc = regex.Matches(s); for (int i = 0; i < args.FieldIndex + 1; i++) s = mc[i * 2].Groups[fieldGroupIndex].Value; } } } }
public void Instance_Deny_Unrestricted () { Regex r = new Regex (String.Empty); Assert.AreEqual (RegexOptions.None, r.Options, "Options"); Assert.IsFalse (r.RightToLeft, "RightToLeft"); Assert.AreEqual (1, r.GetGroupNames ().Length, "GetGroupNames"); Assert.AreEqual (1, r.GetGroupNumbers ().Length, "GetGroupNumbers"); Assert.AreEqual ("0", r.GroupNameFromNumber (0), "GroupNameFromNumber"); Assert.AreEqual (0, r.GroupNumberFromName ("0"), "GroupNumberFromName"); Assert.IsTrue (r.IsMatch (String.Empty), "IsMatch"); Assert.IsTrue (r.IsMatch (String.Empty, 0), "IsMatch2"); Assert.IsNotNull (r.Match (String.Empty), "Match"); Assert.IsNotNull (r.Match (String.Empty, 0), "Match2"); Assert.IsNotNull (r.Match (String.Empty, 0, 0), "Match3"); Assert.AreEqual (1, r.Matches (String.Empty).Count, "Matches"); Assert.AreEqual (1, r.Matches (String.Empty, 0).Count, "Matches2"); Assert.AreEqual (String.Empty, r.Replace (String.Empty, new MatchEvaluator (Evaluator)), "Replace"); Assert.AreEqual (String.Empty, r.Replace (String.Empty, new MatchEvaluator (Evaluator), 0), "Replace2"); Assert.AreEqual (String.Empty, r.Replace (String.Empty, new MatchEvaluator (Evaluator), 0, 0), "Replace3"); Assert.AreEqual (String.Empty, r.Replace (String.Empty, String.Empty), "Replace4"); Assert.AreEqual (String.Empty, r.Replace (String.Empty, String.Empty, 0), "Replace5"); Assert.AreEqual (String.Empty, r.Replace (String.Empty, String.Empty, 0, 0), "Replace6"); Assert.AreEqual (2, r.Split (String.Empty).Length, "Split"); Assert.AreEqual (2, r.Split (String.Empty, 0).Length, "Split2"); Assert.AreEqual (2, r.Split (String.Empty, 0, 0).Length, "Split3"); Assert.AreEqual (String.Empty, r.ToString (), "ToString"); }
/// <summary> /// Adds a System.Web.UI.ScriptResourceDefinition object to the System.Web.UI.ScriptResourceMapping /// object, but only if a file matching the supplied regex pattern is found. If the pattern includes /// a capture group called "ver", it will be used to determine the highest version found. /// </summary> /// <param name="map">The ScriptResourceMapping object.</param> /// <param name="name">The name of the script resource.</param> /// <param name="assembly">A System.Reflection.Assembly object that is used along with the name as the script resource key.</param> /// <param name="definition"> /// A System.Web.UI.ScriptResourceDefinition object that specifies location support /// for script resources. The Path and optionally DebugPath properties should contain /// the path to the virtual folder containing the script to find, e.g. ~/Scripts/ /// </param> /// <param name="fileNamePattern"> /// The regex pattern to match files against. If the pattern includes /// a capture group called "ver", it will be used to determine the highest version found. /// Use ScriptResourceMappingExtensions.VerRegexPattern for a pattern matching standard /// versioning strings, e.g. 1, 1.0, 1.1.2, etc. /// </param> public static void AddDefinitionIfFound(this ScriptResourceMapping map, string name, Assembly assembly, ScriptResourceDefinition definition, string fileNamePattern) { var scriptsFolder = VirtualPathProvider.GetDirectory(definition.Path); if (scriptsFolder == null) { return; } var scripts = scriptsFolder.Files.Cast<VirtualFile>(); var fileNamePatternRegex = new Regex(fileNamePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); var supportVer = fileNamePatternRegex.GroupNumberFromName("ver") >= 0; var foundFile = (from file in scripts let match = fileNamePatternRegex.Match(file.Name) where match.Success let fileVer = supportVer ? GetVersion(match) : null orderby fileVer descending select new { file.Name, Version = fileVer }).FirstOrDefault(); if (foundFile != null) { var ver = foundFile.Version != null ? Regex.Match(foundFile.Name, VerRegexPattern, RegexOptions.IgnoreCase).Groups["ver"].Value : ""; var isMin = foundFile.Name.EndsWith(".min.js", StringComparison.OrdinalIgnoreCase); var fileNamePrefix = foundFile.Name.Substring(0, foundFile.Name.IndexOf(ver + (isMin ? ".min.js" : ".js"))); var altFile = scripts.SingleOrDefault(f => f.Name.Equals( String.Format(isMin ? "{0}{1}.js" : "{0}{1}.min.js", fileNamePrefix, ver), StringComparison.OrdinalIgnoreCase)); var hasBoth = altFile != null; var minFileName = isMin ? foundFile.Name : hasBoth ? altFile.Name : null; var nonMinFileName = !isMin ? foundFile.Name : hasBoth ? altFile.Name : null; var minOnly = isMin && !hasBoth; var path = minOnly || hasBoth ? minFileName : nonMinFileName; var debugPath = hasBoth ? nonMinFileName : null; path = path == null ? null : definition.Path + path; debugPath = debugPath == null ? null : (definition.DebugPath ?? definition.Path) + debugPath; var cdnPath = definition.CdnPath != null ? ver != null ? String.Format(definition.CdnPath, ver) : definition.CdnPath : null; var cdnDebugPath = definition.CdnDebugPath != null ? ver != null ? String.Format(definition.CdnDebugPath, ver) : definition.CdnDebugPath : null; map.AddDefinition(name, assembly, new ScriptResourceDefinition { Path = path, DebugPath = debugPath, CdnPath = cdnPath, CdnDebugPath = cdnDebugPath, CdnSupportsSecureConnection = definition.CdnSupportsSecureConnection }); } }
protected static int GetNumberFromCode(String mask, String code) { var numberRegex = new Regex(mask); var numberMatch = numberRegex.Match(code); var s = numberMatch.Groups[numberRegex.GroupNumberFromName("number")].Value; var numberByCode = 0; if (!int.TryParse(s, out numberByCode)) { throw new Exception("Маска нумератора для объекта не содержит номера"); } return numberByCode; }
private static Regex GetSqlTokenParser() { Regex regex = _sqlTokenParser; if (regex == null) { regex = new Regex(_sqlTokenPattern, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase); _identifierGroup = regex.GroupNumberFromName("identifier"); _quotedidentifierGroup = regex.GroupNumberFromName("quotedidentifier"); _keywordGroup = regex.GroupNumberFromName("keyword"); _stringGroup = regex.GroupNumberFromName("string"); _otherGroup = regex.GroupNumberFromName("other"); _sqlTokenParser = regex; } return regex; }
// ReSharper disable MemberCanBeMadeStatic internal List<AdressedCapture> getNamedCaptureIndex(Match m, string[] groupNames, Regex reg) // ReSharper restore MemberCanBeMadeStatic { var res = new List<AdressedCapture>(); var captureid = 1; var findex = 0; foreach (var groupName in groupNames){ //√руппа с номером 0 всегда попадает в список имен, даже если включена опци¤ ExplicitCapture, это надо отсечь, равно как любые другие не эксплицитные группы if (groupName == "0" || Regex.IsMatch(groupName, "^\\d+$")) continue; findex++; foreach (Capture c in m.Groups[groupName].Captures){ res.Add(new AdressedCapture(captureid, groupName, c, reg.GroupNumberFromName(groupName))); captureid++; } } res.Sort(); return res; }
private void BuildTree(Regex re, Match match) { string[] groups = re.GetGroupNames (); Dictionary<string, int> groupNumbers = new Dictionary<string, int> (); foreach (string groupName in groups) groupNumbers.Add (groupName, re.GroupNumberFromName (groupName)); List<ExprMatchGroup> emgList = new List<ExprMatchGroup> (); for (int i = 0; i < groups.Length; i++) { string groupName = groups [i]; if (groupName != "0") { Group group = match.Groups [groupName]; if (group.Success) { for (int j = 0; j < group.Captures.Count; j++) { Capture cap = group.Captures [j]; emgList.Add (new ExprMatchGroup (groupName, cap.Value, cap.Index, cap.Length)); } } } } emgList.Sort (new Comparison<ExprMatchGroup> ((emg1, emg2) => { int c = emg1.StartIndex.CompareTo (emg2.StartIndex); if (c == 0) c = -1 * emg1.EndIndex.CompareTo (emg2.EndIndex); if (c == 0) { if (emg1.Name == BadrGrammar.GROUP_VARIABLE_VALUE) return 1; else if (emg2.Name == BadrGrammar.GROUP_VARIABLE_VALUE) return -1; } return c; })); for (int i = 0; i < emgList.Count; i++) { Add (emgList [i], true); } }
/// <summary> /// Returns the group number that corresponds to the specified group name. /// </summary> /// <param name="name">Group name to be converted to the corresponding group number.</param> /// <returns>Group number corresponding to the specified group <paramref name="name"/>, or -1 if <paramref name="name"/> is not a valid group <paramref name="name"/>.</returns> /// <exception cref="ArgumentNullException">name has the value null.</exception> public int GroupNumberFromName(string name) { return(_regex.GroupNumberFromName(name)); }
private string ValidateReplacementPattern(XmlReader reader, Regex find, string repl) { var sb = new StringBuilder(repl).Append('\0'); int index = -1; int mode = 0; while (++index < sb.Length) { char c = sb[index]; switch (mode) { case 0: if (c == '$') { mode = 2; } break; case 1: // $$ if ("0123456789{".IndexOf(c) >= 0) { _factory.Warn(reader, string.Format("replaceWith=\"{0}\" - Perhaps you meant \"{1}${2}\"?", repl, sb.ToString(0, index), c)); } index -= 1; mode = 0; break; case 2: // $ mode = 0; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': mode = 3; break; case '{': mode = 4; break; case '$': mode = 1; break; case '\'': case '`': case '_': _factory.Warn(reader, string.Format("replaceWith=\"{0}\" - Are you sure you want \"${1}\" in the replacement pattern?", repl, c)); break; case '&': case '+': break; default: sb.Insert(index, '$'); _factory.Verbose(reader, string.Format("replaceWith=\"{0}\" - Missing '$' inserted: \"{1}\"", repl, sb.ToString(0, index + 1))); break; } break; case 3: // $[0-9]+ if ("0123456789".IndexOf(c) < 0) { var start = sb.ToString(0, index).LastIndexOf('$') + 1; var group = sb.ToString(start, index - start); if (find.GroupNumberFromName(group) < 0) { _factory.Warn(reader, string.Format("replaceWith=\"{0}\" - Group \"{1}\" is not defined in the regular expression pattern!", repl, group)); } index -= 1; mode = 0; } break; case 4: // ${ mode = 5; if ("_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".IndexOf(c) < 0) { _factory.Warn(reader, string.Format("replaceWith=\"{0}\" - Invalid group identifier \"{1}\"?", repl, sb.ToString(index - 2, 3))); index -= 1; mode = 0; } break; case 5: // ${[0-9A-Za-z]+ if (c == '}') { var start = sb.ToString(0, index).LastIndexOf('{') + 1; var group = sb.ToString(start, index - start); if (find.GroupNumberFromName(group) < 0) { _factory.Warn(reader, string.Format("replaceWith=\"{0}\" - Group \"{1}\" is not defined in the regular expression pattern!", repl, group)); } mode = 0; } else if ("_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".IndexOf(c) < 0) { var start = sb.ToString(0, index).LastIndexOf('$'); _factory.Warn(reader, string.Format("replaceWith=\"{0}\" - Invalid group identifier \"{1}\"?", repl, sb.ToString(start, index - start))); index -= 1; mode = 0; } break; } } return sb.ToString(0, sb.Length - 1); }
private static Regex GetSqlTokenParser() { Regex regex = _sqlTokenParser; if (regex == null) { regex = new Regex(_sqlTokenPattern, RegexOptions.ExplicitCapture); _commentGroup = regex.GroupNumberFromName("comment"); _identifierGroup = regex.GroupNumberFromName("identifier"); _parameterMarkerGroup = regex.GroupNumberFromName("parametermarker"); _queryGroup = regex.GroupNumberFromName("query"); _stringGroup = regex.GroupNumberFromName("string"); _otherGroup = regex.GroupNumberFromName("other"); _sqlTokenParser = regex; } return regex; }
/// <summary> /// Check if a specific .NET Framework version is installed. /// </summary> /// <param name="version">version to test</param> /// <returns>True if installed</returns> public static bool IsVersionInstalled(FrameworkVersions version) { try { switch (version) { case FrameworkVersions.Mono_2_4: if (!string.IsNullOrEmpty(MonoVersion)) { var regex = new Regex(@"^Mono (?<major>\d+)\.(?<minor>\d+)(\..*)?$"); if (regex.IsMatch(MonoVersion)) { var items = regex.Split(MonoVersion); var major = Convert.ToInt32(items[regex.GroupNumberFromName("major")]); var minor = Convert.ToInt32(items[regex.GroupNumberFromName("minor")]); return (major == 2 && minor >= 4) || (major >= 3); } } break; default: var masterKey = Registry.LocalMachine.OpenSubKey(RegLocation); if (masterKey != null) { var subKeyNames = masterKey.GetSubKeyNames(); if (subKeyNames.Any(ver => ver.ToLower().Replace(".", "_") == version.ToString())) return true; } break; } } catch (Exception) { return false; } return false; }
public GroupImpl FromName(string inputName) { int index = _regex.GroupNumberFromName(inputName); return(new GroupImpl(_groups[(int)index], (int)index, _regex)); }