/// <summary> /// Add an existing <see cref="RegexNegativeLookbehindAssertionNode"/> to the generator. /// </summary> /// <param name="group"><see cref="RegexNegativeLookbehindAssertionNode"/> to be added.</param> /// <returns><see cref="RegexGenerator"/></returns> /// <exception cref="NegativeLookbehindAssertionNotSupportedException">Negative lookbehind assertion is not supported by <see cref="RegexLanguage"/>.</exception> public RegexGenerator AddNegativeLookbehindAssertion(RegexNegativeLookbehindAssertionNode negativeLookbehindAssertion) { if (!IsNegativeLookbehindAssertionSupported) { throw new NegativeLookbehindAssertionNotSupportedException(RegexLanguage); } return(Add(negativeLookbehindAssertion)); }
public virtual string ToNegativeLookbehindAssertionString(RegexNegativeLookbehindAssertionNode negativeLookbehindAssertion) { if (!IsNegativeLookbehindAssertionSupported) { throw new NegativeLookbehindAssertionNotSupportedException(RegexLanguage); } if (negativeLookbehindAssertion == null) { throw new ArgumentNullException(nameof(negativeLookbehindAssertion)); } var sb = new StringBuilder(); sb.Append(ToTokenString(RegexToken.NegativeLookbehindAssertionOpen)) .Append(negativeLookbehindAssertion.IsInnerNodeIncluded ? ToString(negativeLookbehindAssertion.InnerNode) : negativeLookbehindAssertion.Pattern) .Append(ToTokenString(RegexToken.NegativeLookbehindAssertionClose)); return(AddQuantifier(sb.ToString(), negativeLookbehindAssertion.Minimum, negativeLookbehindAssertion.Maximum, negativeLookbehindAssertion.RegexQuantifierOption)); }
/// <summary> /// Create and add <see cref="RegexNegativeLookbehindAssertionNode"/> 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="NegativeLookbehindAssertionNotSupportedException">Negative lookbehind assertion is not supported by <see cref="RegexLanguage"/>.</exception> public RegexGenerator AddNegativeLookbehindAssertion(RegexNode innerNode, int?min = null, int?max = null, RegexQuantifierOption quantifierOption = RegexQuantifierOption.Greedy) { var negativeLookbehindAssertion = new RegexNegativeLookbehindAssertionNode(innerNode, min, max, quantifierOption); return(AddNegativeLookbehindAssertion(negativeLookbehindAssertion)); }