private static void GetRegexRow( object matchObject, out SqlInt32 groupNumber, out SqlInt32 index, out SqlInt32 length, out SqlInt32 matchNumber, out SqlString value, out SqlString groupName) { if (matchObject != null) { MatchGroupRow match = (MatchGroupRow)matchObject; groupNumber = match.GroupNumber; index = match.Index; length = match.Length; matchNumber = match.MatchNumber; value = match.Value; groupName = string.IsNullOrEmpty(match.GroupName) ? SqlString.Null : new SqlString(match.GroupName); } else { groupNumber = SqlInt32.Null; index = SqlInt32.Null; length = SqlInt32.Null; matchNumber = SqlInt32.Null; value = SqlString.Null; groupName = SqlString.Null; } }
public static ArrayList Match(SqlString inputText, SqlString pattern, bool isCaseSensitive) { ArrayList result = new ArrayList(); try { if (!inputText.IsNull && !string.IsNullOrEmpty(inputText.Value) && !pattern.IsNull && !string.IsNullOrEmpty(pattern.Value) ) { TextRegex regex = isCaseSensitive ? new TextRegex(pattern.Value) : new TextRegex(pattern.Value, RegexOptions.IgnoreCase); MatchCollection matches = regex.Matches(inputText.Value); for (int matchNumber = 0; matchNumber < matches.Count; ++matchNumber) { Match match = matches[matchNumber]; for (int groupNumber = 1; groupNumber < match.Groups.Count; ++groupNumber) { Group group = match.Groups[groupNumber]; string groupName = regex.GroupNameFromNumber(groupNumber); MatchGroupRow resultItem = new MatchGroupRow { GroupName = groupName, GroupNumber = groupNumber, Index = group.Index, Length = group.Length, MatchNumber = matchNumber, Value = group.Value }; result.Add(resultItem); } } } } catch { // ignored } return(result); }