/// <summary> /// Add an existing <see cref="RegexPositiveLookaheadAssertionNode"/> to the generator. /// </summary> /// <param name="group"><see cref="RegexPositiveLookaheadAssertionNode"/> to be added.</param> /// <returns><see cref="RegexGenerator"/></returns> /// <exception cref="PositiveLookaheadAssertionNotSupportedException">Positive lookahead assertion is not supported by <see cref="RegexLanguage"/>.</exception> public RegexGenerator AddPositiveLookaheadAssertion(RegexPositiveLookaheadAssertionNode positiveLookaheadAssertion) { if (!IsPositiveLookaheadAssertionSupported) { throw new PositiveLookaheadAssertionNotSupportedException(RegexLanguage); } return(Add(positiveLookaheadAssertion)); }
public virtual string ToPositiveLookaheadAssertionString(RegexPositiveLookaheadAssertionNode positiveLookaheadAssertion) { if (!IsPositiveLookaheadAssertionSupported) { throw new PositiveLookaheadAssertionNotSupportedException(RegexLanguage); } if (positiveLookaheadAssertion == null) { throw new ArgumentNullException(nameof(positiveLookaheadAssertion)); } var sb = new StringBuilder(); sb.Append(ToTokenString(RegexToken.PositiveLookaheadAssertionOpen)) .Append(positiveLookaheadAssertion.IsInnerNodeIncluded ? ToString(positiveLookaheadAssertion.InnerNode) : positiveLookaheadAssertion.Pattern) .Append(ToTokenString(RegexToken.PositiveLookaheadAssertionClose)); return(AddQuantifier(sb.ToString(), positiveLookaheadAssertion.Minimum, positiveLookaheadAssertion.Maximum, positiveLookaheadAssertion.RegexQuantifierOption)); }
/// <summary> /// Create and add <see cref="RegexPositiveLookaheadAssertionNode"/> to the generator, and include another <see cref="RegexNode"/> inside. /// </summary> /// <param name="innerNode">An existing <see cref="RegexNode"/> to be included.</param> /// <param name="min">Optional minimum number of occurance.</param> /// <param name="max">Optional maximum number of occurance.</param> /// <param name="quantifierOption">Optional quantifier option.</param> /// <returns><see cref="RegexGenerator"/></returns> /// <exception cref="PositiveLookaheadAssertionNotSupportedException">Positive lookahead assertion is not supported by <see cref="RegexLanguage"/>.</exception> public RegexGenerator AddPositiveLookaheadAssertion(RegexNode innerNode, int?min = null, int?max = null, RegexQuantifierOption quantifierOption = RegexQuantifierOption.Greedy) { var positiveLookaheadAssertion = new RegexPositiveLookaheadAssertionNode(innerNode, min, max, quantifierOption); return(AddPositiveLookaheadAssertion(positiveLookaheadAssertion)); }