コード例 #1
0
 public RegexNodeAlternation(RegexNode expression1, RegexNode expression2)
 {
     if (expression1 == null || expression2 == null)
     {
         throw new ArgumentNullException(string.Empty, "Expressions cannot be null");
     }
     expressions = new[] { expression1, expression2 };
 }
コード例 #2
0
ファイル: RegexNode.cs プロジェクト: ruo2012/regex-builder
        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));
        }
コード例 #3
0
ファイル: RegexNode.cs プロジェクト: YuriyGuts/regex-builder
        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);
        }
コード例 #4
0
 public RegexNodeConditionalMatch(string conditionGroupName, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionGroupName = conditionGroupName;
     TrueMatchExpression = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
コード例 #5
0
 public RegexNodeBacktrackingSuppression(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
 }
コード例 #6
0
 public RegexNodeGroup(RegexNode innerExpression, bool isCapturing)
 {
     InnerExpression = innerExpression;
     IsCapturing     = isCapturing;
 }
コード例 #7
0
 public RegexNodeInlineOption(RegexOptions options, RegexNode innerExpression)
 {
     Options         = options;
     InnerExpression = innerExpression;
 }
コード例 #8
0
 public RegexNodeConditionalMatch(string conditionGroupName, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionGroupName   = conditionGroupName;
     TrueMatchExpression  = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
コード例 #9
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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));
 }
コード例 #10
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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
     });
 }
コード例 #11
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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
     });
 }
コード例 #12
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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));
 }
コード例 #13
0
 public RegexNodeBacktrackingSuppression(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
 }
コード例 #14
0
 public RegexNodeLookAround(RegexLookAround lookAroundType, RegexNode lookAroundExpression, RegexNode matchExpression)
 {
     LookAroundType       = lookAroundType;
     LookAroundExpression = lookAroundExpression;
     MatchExpression      = matchExpression;
 }
コード例 #15
0
 public RegexNodeGroup(RegexNode innerExpression, string name)
 {
     InnerExpression = innerExpression;
     IsCapturing = true;
     Name = name;
 }
コード例 #16
0
 public RegexNodeGroup(RegexNode innerExpression, bool isCapturing)
 {
     InnerExpression = innerExpression;
     IsCapturing = isCapturing;
 }
コード例 #17
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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
     });
 }
コード例 #18
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <summary>
 /// Generates a zero-width negative lookbehind assertion ("(?&lt;!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));
 }
コード例 #19
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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 }));
 }
コード例 #20
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <summary>
 /// Generates a zero-width negative lookbehind assertion ("(?&lt;!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
     });
 }
コード例 #21
0
 public RegexNodeConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionExpression  = conditionExpression;
     TrueMatchExpression  = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
コード例 #22
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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));
 }
コード例 #23
0
 public RegexNodeLookAround(RegexLookAround lookAroundType, RegexNode lookAroundExpression, RegexNode matchExpression)
 {
     LookAroundType = lookAroundType;
     LookAroundExpression = lookAroundExpression;
     MatchExpression = matchExpression;
 }
コード例 #24
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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));
 }
コード例 #25
0
 public RegexNodeGroup(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
     IsCapturing     = true;
 }
コード例 #26
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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));
 }
コード例 #27
0
 public RegexNodeGroup(RegexNode innerExpression, string name)
 {
     InnerExpression = innerExpression;
     IsCapturing     = true;
     Name            = name;
 }
コード例 #28
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <summary>
 /// Generates a subexpression with disabled backtracking ("(?&gt;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));
 }
コード例 #29
0
 public RegexNodeConditionalMatch(RegexNode conditionExpression, RegexNode trueMatchExpression, RegexNode falseMatchExpression)
 {
     ConditionExpression = conditionExpression;
     TrueMatchExpression = trueMatchExpression;
     FalseMatchExpression = falseMatchExpression;
 }
コード例 #30
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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));
 }
コード例 #31
0
ファイル: RegexBuilder.cs プロジェクト: ruo2012/regex-builder
 /// <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));
 }
コード例 #32
0
 public RegexNodeGroup(RegexNode innerExpression)
 {
     InnerExpression = innerExpression;
     IsCapturing = true;
 }