/// <summary> /// Gets the first match group from the specified match. /// </summary> /// <param name="g">The group collection.</param> /// <param name="predicate">The predicate.</param> /// <returns></returns> /// <exception cref="System.InvalidOperationException"></exception> public static Group First(this GroupCollection g, Func <Group, bool> predicate) { var result = g.FirstOrDefault(x => predicate(x)); if (result == default(Group)) { throw new InvalidOperationException(Resources.Sequence_Empty); } return(result); }
/// <summary> /// Gets the first match group from the specified match. /// </summary> /// <param name="g">The group collection.</param> /// <returns></returns> public static Group FirstOrDefault(this GroupCollection g) { return(g.FirstOrDefault(x => true)); }