public RegexNodeAlternation(RegexNode expression1, RegexNode expression2) { if (expression1 == null || expression2 == null) { throw new ArgumentNullException(string.Empty, "Expressions cannot be null"); } expressions = new[] { expression1, expression2 }; }
public static RegexNode Add(RegexNode node1, RegexNode node2) { if (node1 == null || node2 == null) { throw new ArgumentException("Both nodes must be not null."); } RegexNodeConcatenation node1AsConcatenation = node1 as RegexNodeConcatenation; RegexNodeConcatenation node2AsConcatenation = node2 as RegexNodeConcatenation; if (node1AsConcatenation != null && node2AsConcatenation != null) { List <RegexNode> newChildNodes = new List <RegexNode>(); newChildNodes.AddRange(node1AsConcatenation.ChildNodes); newChildNodes.AddRange(node2AsConcatenation.ChildNodes); RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes); return(result); } if (node1AsConcatenation != null) { List <RegexNode> newChildNodes = new List <RegexNode>(node1AsConcatenation.ChildNodes); newChildNodes.Add(node2); RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes); return(result); } if (node2AsConcatenation != null) { List <RegexNode> newChildNodes = new List <RegexNode>(); newChildNodes.Add(node1); newChildNodes.AddRange(node2AsConcatenation.ChildNodes); RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes); return(result); } return(new RegexNodeConcatenation(node1, node2)); }
public static RegexNode Add(RegexNode node1, RegexNode node2) { if (node1 == null || node2 == null) { throw new ArgumentException("Both nodes must be not null."); } RegexNodeConcatenation node1AsConcatenation = node1 as RegexNodeConcatenation; RegexNodeConcatenation node2AsConcatenation = node2 as RegexNodeConcatenation; if (node1AsConcatenation != null && node2AsConcatenation != null) { List<RegexNode> newChildNodes = new List<RegexNode>(); newChildNodes.AddRange(node1AsConcatenation.ChildNodes); newChildNodes.AddRange(node2AsConcatenation.ChildNodes); RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes); return result; } if (node1AsConcatenation != null) { List<RegexNode> newChildNodes = new List<RegexNode>(node1AsConcatenation.ChildNodes); newChildNodes.Add(node2); RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes); return result; } if (node2AsConcatenation != null) { List<RegexNode> newChildNodes = new List<RegexNode>(); newChildNodes.Add(node1); newChildNodes.AddRange(node2AsConcatenation.ChildNodes); RegexNodeConcatenation result = new RegexNodeConcatenation(newChildNodes); return result; } return new RegexNodeConcatenation(node1, node2); }
public RegexNodeConditionalMatch(string conditionGroupName, RegexNode trueMatchExpression, RegexNode falseMatchExpression) { ConditionGroupName = conditionGroupName; TrueMatchExpression = trueMatchExpression; FalseMatchExpression = falseMatchExpression; }
public RegexNodeBacktrackingSuppression(RegexNode innerExpression) { InnerExpression = innerExpression; }
public RegexNodeGroup(RegexNode innerExpression, bool isCapturing) { InnerExpression = innerExpression; IsCapturing = isCapturing; }
public RegexNodeInlineOption(RegexOptions options, RegexNode innerExpression) { Options = options; InnerExpression = innerExpression; }
/// <summary> /// Concatenates four nodes. /// </summary> /// <param name="node1">First node.</param> /// <param name="node2">Second node.</param> /// <param name="node3">Third node.</param> /// <param name="node4">Fourth node.</param> /// <param name="quantifier">Node quantifier.</param> /// <returns>An instance of RegexNode representing the concatenation of child nodes.</returns> public static RegexNodeConcatenation Concatenate(RegexNode node1, RegexNode node2, RegexNode node3, RegexNode node4, RegexQuantifier quantifier) { return(Concatenate(new[] { node1, node2, node3, node4 }, quantifier)); }
/// <summary> /// Generates a conditional match expression which uses a named group for condition evaluation ("(?(GroupName)|(true)|(false))"). /// </summary> /// <param name="conditionGroupName">The name of the group to be used as a condition.</param> /// <param name="trueMatchExpression">True match expression.</param> /// <param name="falseMatchExpression">False match expression.</param> /// <param name="quantifier">Node quantifier.</param> /// <returns>An instance of RegexNode containing the conditional match expression.</returns> public static RegexNodeConditionalMatch ConditionalMatch(string conditionGroupName, RegexNode trueMatchExpression, RegexNode falseMatchExpression, RegexQuantifier quantifier) { return(new RegexNodeConditionalMatch(conditionGroupName, trueMatchExpression, falseMatchExpression) { Quantifier = quantifier }); }
/// <summary> /// Generates a zero-width positive lookahead assertion ("match(?=lookahead)"). /// </summary> /// <param name="lookupExpression">Lookahead expression.</param> /// <param name="matchExpression">Match expression.</param> /// <param name="quantifier">Node quantifier.</param> /// <returns>An instance of RegexNode containing the positive lookahead assertion.</returns> public static RegexNodeLookAround PositiveLookAhead(RegexNode lookupExpression, RegexNode matchExpression, RegexQuantifier quantifier) { return(new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, lookupExpression, matchExpression) { Quantifier = quantifier }); }
/// <summary> /// Generates a zero-width positive lookahead assertion ("match(?=lookahead)"). /// </summary> /// <param name="lookupExpression">Lookahead expression.</param> /// <param name="matchExpression">Match expression.</param> /// <returns>An instance of RegexNode containing the positive lookahead assertion.</returns> public static RegexNodeLookAround PositiveLookAhead(RegexNode lookupExpression, RegexNode matchExpression) { return(new RegexNodeLookAround(RegexLookAround.PositiveLookAhead, lookupExpression, matchExpression)); }
public RegexNodeLookAround(RegexLookAround lookAroundType, RegexNode lookAroundExpression, RegexNode matchExpression) { LookAroundType = lookAroundType; LookAroundExpression = lookAroundExpression; MatchExpression = matchExpression; }
public RegexNodeGroup(RegexNode innerExpression, string name) { InnerExpression = innerExpression; IsCapturing = true; Name = name; }
/// <summary> /// Generates a conditional match expression ("(?(condition)|(true)|(false))"). /// </summary> /// <param name="conditionExpression">Condition expression.</param> /// <param name="trueMatchExpression">True match expression.</param> /// <param name="falseMatchExpression">False match expression.</param> /// <param name="quantifier">Node quantifier.</param> /// <returns>An instance of RegexNode containing the conditional match expression.</returns> public static RegexNodeConditionalMatch ConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression, RegexQuantifier quantifier) { return(new RegexNodeConditionalMatch(conditionExpression, trueMatchExpression, falseMatchExpression) { Quantifier = quantifier }); }
/// <summary> /// Generates a zero-width negative lookbehind assertion ("(?<!lookbehind)match"). /// </summary> /// <param name="lookupExpression">Lookbehind expression.</param> /// <param name="matchExpression">Match expression.</param> /// <returns>An instance of RegexNode containing the negative lookbehind assertion.</returns> public static RegexNodeLookAround NegativeLookBehind(RegexNode lookupExpression, RegexNode matchExpression) { return(new RegexNodeLookAround(RegexLookAround.NegativeLookBehind, lookupExpression, matchExpression)); }
/// <summary> /// Concatenates four nodes. /// </summary> /// <param name="node1">First node.</param> /// <param name="node2">Second node.</param> /// <param name="node3">Third node.</param> /// <param name="node4">Fourth node.</param> /// <returns>An instance of RegexNode representing the concatenation of child nodes.</returns> public static RegexNodeConcatenation Concatenate(RegexNode node1, RegexNode node2, RegexNode node3, RegexNode node4) { return(Concatenate(new[] { node1, node2, node3, node4 })); }
/// <summary> /// Generates a zero-width negative lookbehind assertion ("(?<!lookbehind)match"). /// </summary> /// <param name="lookupExpression">Lookbehind expression.</param> /// <param name="matchExpression">Match expression.</param> /// <param name="quantifier">Node quantifier.</param> /// <returns>An instance of RegexNode containing the negative lookbehind assertion.</returns> public static RegexNodeLookAround NegativeLookBehind(RegexNode lookupExpression, RegexNode matchExpression, RegexQuantifier quantifier) { return(new RegexNodeLookAround(RegexLookAround.NegativeLookBehind, lookupExpression, matchExpression) { Quantifier = quantifier }); }
public RegexNodeConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression) { ConditionExpression = conditionExpression; TrueMatchExpression = trueMatchExpression; FalseMatchExpression = falseMatchExpression; }
/// <summary> /// Generates an unnamed capturing group with the specified subexpression. /// </summary> /// <param name="matchExpression">Inner expression.</param> /// <returns>An instance of RegexNode containing the unnamed capturing group.</returns> public static RegexNodeGroup Group(RegexNode matchExpression) { return(new RegexNodeGroup(matchExpression)); }
/// <summary> /// Generates a named capturing group with the specified subexpression. /// </summary> /// <param name="groupName">Group name.</param> /// <param name="matchExpression">Inner expression.</param> /// <returns>An instance of RegexNode containing the named capturing group.</returns> public static RegexNodeGroup Group(string groupName, RegexNode matchExpression) { return(new RegexNodeGroup(matchExpression, groupName)); }
public RegexNodeGroup(RegexNode innerExpression) { InnerExpression = innerExpression; IsCapturing = true; }
/// <summary> /// Generates a non-capturing group with the specified subexpression. /// </summary> /// <param name="matchExpression">Inner expression.</param> /// <returns>An instance of RegexNode containing the non-capturing group.</returns> public static RegexNodeGroup NonCapturingGroup(RegexNode matchExpression) { return(new RegexNodeGroup(matchExpression, false)); }
/// <summary> /// Generates a subexpression with disabled backtracking ("(?>expression)"). /// </summary> /// <param name="innerExpression">Inner expression.</param> /// <returns>An instance of RegexNode containing the expression with suppressed backtracking.</returns> public static RegexNodeBacktrackingSuppression BacktrackingSuppression(RegexNode innerExpression) { return(new RegexNodeBacktrackingSuppression(innerExpression)); }
/// <summary> /// Generates an alternation expression with two options ("a|b"). /// </summary> /// <param name="expression1">First option.</param> /// <param name="expression2">Second option.</param> /// <returns>An instance of RegexNode containing the alternation expression.</returns> public static RegexNodeAlternation Alternate(RegexNode expression1, RegexNode expression2) { return(new RegexNodeAlternation(expression1, expression2)); }
/// <summary> /// Generates a conditional match expression ("(?(condition)|(true)|(false))"). /// </summary> /// <param name="conditionExpression">Condition expression.</param> /// <param name="trueMatchExpression">True match expression.</param> /// <param name="falseMatchExpression">False match expression.</param> /// <returns>An instance of RegexNode containing the conditional match expression.</returns> public static RegexNodeConditionalMatch ConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression) { return(new RegexNodeConditionalMatch(conditionExpression, trueMatchExpression, falseMatchExpression)); }