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