private static IEnumerable<string> GetTags(Capture extraInfoGroup)
 {
     char[] separators = { '.', ' ', '-', '_' };
     var extraInfo = extraInfoGroup.Value;
     var tags = extraInfo.Split(separators);
     return tags.Select(e => e.Trim());
 }
        private void FindPrev_Click(object sender, EventArgs e)
        {
            try
            {
                RichTextBox TextBox = null;
                TextBox = this.TextBox;

                int length = 0;
                if (TextBox.SelectionStart >= 0)
                {
                    length = TextBox.SelectionStart;
                }

                string text = TextBox.Text.Substring(0, length);
                Match  m    = Regex.Match(text, FindBox.Text, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.RightToLeft);
                if (m.Success)
                {
                    System.Text.RegularExpressions.Capture c = m.Groups[0].Captures[0];
                    TextBox.Select(c.Index, c.Length);
                }
                else
                {
                    FindPrev.Enabled = false;
                }

                FindNext.Enabled = true;
            }
            catch (Exception ex)
            {
                Message.Error(ex);
            }
        }
        void find_next()
        {
            try
            {
                RichTextBox TextBox = null;
                TextBox = this.TextBox;

                int start = 0;
                if (TextBox.SelectionStart >= 0)
                {
                    start = TextBox.SelectionStart + TextBox.SelectionLength;
                }

                string text = TextBox.Text.Substring(start);
                Match  m    = Regex.Match(text, FindBox.Text, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (m.Success)
                {
                    System.Text.RegularExpressions.Capture c = m.Groups[0].Captures[0];
                    TextBox.Select(start + c.Index, c.Length);
                }
                else
                {
                    FindNext.Enabled = false;
                }

                FindPrev.Enabled = true;
            }
            catch (Exception ex)
            {
                Message.Error(ex);
            }
        }
    static void Capture_Value(JSVCall vc)
    {
        System.Text.RegularExpressions.Capture _this = (System.Text.RegularExpressions.Capture)vc.csObj;
        var result = _this.Value;

        JSApi.setStringS((int)JSApi.SetType.Rval, result);
    }
    static void Capture_Length(JSVCall vc)
    {
        System.Text.RegularExpressions.Capture _this = (System.Text.RegularExpressions.Capture)vc.csObj;
        var result = _this.Length;

        JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
    }
		private static string GetTypedViewName(Capture view)
		{
			if (view == null || string.IsNullOrEmpty(view.Value))
				return null;

			// strip .NET standard generic notation

			if (view.Value.IndexOf('`')<0)
			{
				if (view.Value.IndexOf(',') > -1)
					throw new AspViewException("Basetype for views cannot be of a generic type with more than a single type parameter. found \"{0}\"", view.Value);
				
				return view.Value;
			}

			for (var i=2; i <=10; ++i)
				if (view.Value.Contains("`"+i))
					throw new AspViewException("Basetype for views cannot be of a generic type with more than a single type parameter. found \"{0}\"", view.Value);

			var viewTypeName = view.Value
				.Replace("`1[[", "<")
				.Replace("`1[", "<")
				.Replace("]]", ">")
				.Replace("]", ">");
			
			return viewTypeName.Split(new[]{','})[0].Trim();
		}
 private TreeNode AddSubNode(int parentNodeIndex, string caption, Capture matchCapture, int groupIndex, int captureIndex)
 {
     TreeNode node = Nodes[parentNodeIndex].Nodes[groupIndex - 1];
     TreeNode subNode = makeCaptureNode(caption);
     node.Nodes.Add(subNode);
     node.Nodes[captureIndex].Tag = matchCapture;
     return subNode;
 }
        private void PropertyMatch(ref string source, System.Text.RegularExpressions.Capture capture)
        {
            string propertyName = BuildTaskUtility.PropertyNameFromCapture(capture);

            string propertyValue = GetEvaluatedProperty(propertyName);

            source.Replace(capture.Value, propertyValue);
        }
Beispiel #9
0
        protected static string SubstituteKownValue(string transformValue, RegularExpressions.Regex patternRegex, string patternPrefix, GetValueCallback getValueDelegate)
        {
            var position   = 0;
            var matchsExpr = new List <RegularExpressions.Match>();

            do
            {
                position = transformValue.IndexOf(patternPrefix, position, StringComparison.OrdinalIgnoreCase);
                if (position > -1)
                {
                    RegularExpressions.Match match = patternRegex.Match(transformValue, position);
                    // Add the successful match to collection
                    if (match.Success)
                    {
                        matchsExpr.Add(match);
                        position = match.Index + match.Length;
                    }
                    else
                    {
                        position++;
                    }
                }
            } while (position > -1);

            var strbuilder = new StringBuilder(transformValue.Length);

            if (matchsExpr.Count > 0)
            {
                strbuilder.Remove(0, strbuilder.Length);
                position = 0;
                var index = 0;
                foreach (RegularExpressions.Match match in matchsExpr)
                {
                    strbuilder.Append(transformValue.Substring(position, match.Index - position));
                    RegularExpressions.Capture captureTagName = match.Groups["tagname"];
                    string attributeName = captureTagName.Value;

                    string newValue = getValueDelegate(attributeName);

                    if (newValue != null) // null indicate that the attribute is not exist
                    {
                        strbuilder.Append(newValue);
                    }
                    else
                    {
                        // keep original value
                        strbuilder.Append(match.Value);
                    }
                    position = match.Index + match.Length;
                    index++;
                }
                strbuilder.Append(transformValue.Substring(position));

                transformValue = strbuilder.ToString();
            }

            return(transformValue);
        }
        private static bool AreDelimiterGroupsEmpty(Capture singleCharDelimiterGroup, Capture multiCharDelimiterGroup)
        {
            if (singleCharDelimiterGroup == null || multiCharDelimiterGroup == null)
            {
                return true;
            }

            return (singleCharDelimiterGroup.Length + multiCharDelimiterGroup.Length) < 1;
        }
Beispiel #11
0
		public void Deny_Unrestricted ()
		{
			Assert.AreEqual (0, coll.Count, "Count");
			Assert.IsTrue (coll.IsReadOnly, "IsReadOnly");
			Assert.IsFalse (coll.IsSynchronized, "IsSynchronized");
			Assert.IsNotNull (coll.SyncRoot, "SyncRoot");

			Assert.IsNotNull (coll.GetEnumerator (), "GetEnumerator");
			Capture[] captures = new Capture[0];
			coll.CopyTo (captures, 0);
		}
Beispiel #12
0
 static public int get_Value(IntPtr l)
 {
     try {
         System.Text.RegularExpressions.Capture self = (System.Text.RegularExpressions.Capture)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.Value);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        private static void ExpandEnvironmentMatch(ref string source, Capture capture)
        {
            string envVar = PropertyNameFromCapture(capture);

            string expandedVar = Environment.ExpandEnvironmentVariables("%" + envVar + "%");

            if (expandedVar != null)
            {
                source = source.Replace(capture.Value, expandedVar);
            }

        }
Beispiel #14
0
 static new public int ToString(IntPtr l)
 {
     try {
         System.Text.RegularExpressions.Capture self = (System.Text.RegularExpressions.Capture)checkSelf(l);
         var ret = self.ToString();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 private void EvaluateCaptureAfterFirstGroup(Capture capture, int index, int length)
 {
     var isGherkinKeyword =
         this.gherkinLanguageKeywords.Any(gherkinKeyword => string.CompareOrdinal(gherkinKeyword, capture.Value) == 0);
     if (isGherkinKeyword)
     {
         this.syntaxParserObserver.AddGherkinSyntaxSpanAt(index, length);
     }
     else
     {
         this.syntaxParserObserver.AddPascalCaseSpanAt(index, length);
     }
 }
 private int addSnippetAndReturnNewIndex(string text, FontStyle style, Capture capture, int currentindex)
 {
     int index = currentindex;
     if (text != string.Empty)
     {
         addSnippet(text, style);
         index = capture.Index + capture.Length;
     }
     else
     {
         index += capture.Length;
     }
     return index;
 }
Beispiel #17
0
        private string GetValue(List<Capture> captures, Capture capture, Domain domain)
        {
            var lastCapture = captures.Where(x => x.Index < capture.Index).OrderByDescending(x => x.Index).FirstOrDefault();

            if ((lastCapture != null) && (lastCapture.Value.Equals("{")))
            {
                var childDomain = domain.GetChildDomain(capture.Value);

                if ((childDomain.GetType().Name.Contains("EntityDomain")) && (childDomain.ObjectValue != null))
                {
                    return childDomain.ObjectValue.ToString();
                }

                return (childDomain.Value ?? string.Empty).ToString();
            }

            return capture.Value;
        }
		private static string GetBaseClass(Capture baseClass)
		{
			if (baseClass == null)
				return DefaultBaseClassName;

			if (string.IsNullOrEmpty(baseClass.Value))
				return DefaultBaseClassName;

			if (baseClass.Value == DefaultDesignTimeClassName)
				return DefaultBaseClassName;

			var extractedName = baseClass.Value;

			if (extractedName.EndsWith(DesignTimeClassPrefix))
				extractedName = extractedName.Substring(0, extractedName.Length - DesignTimeClassPrefix.Length);

			return extractedName;
		}
        /// <summary>
        /// Returns the set of captures for the group
        /// </summary>
        private Capture GetCapture(int i)
        {
            if (i == _capcount - 1 && i >= 0)
                return _group;

            if (i >= _capcount || i < 0)
                throw new ArgumentOutOfRangeException("i");

            // first time a capture is accessed, compute them all
            if (_captures == null)
            {
                _captures = new Capture[_capcount];
                for (int j = 0; j < _capcount - 1; j++)
                {
                    _captures[j] = new Capture(_group._text, _group._caps[j * 2], _group._caps[j * 2 + 1]);
                }
            }

            return _captures[i];
        }
 string value_from(string argument_name, Capture match)
 {
     var replace = match.Value.Replace("-{0}:'".format_using(argument_name), "");
     return replace.Remove(replace.Length - 1, 1);
 }
 private static int ExtractEndEpisode(Capture endEpisodeGroup, int episode)
 {
     return !string.IsNullOrEmpty(endEpisodeGroup.Value) ? int.Parse(endEpisodeGroup.Value) : episode;
 }
Beispiel #22
0
 internal void Add(Capture capture)
 {
     captures.Add(capture);
 }
Beispiel #23
0
        private HashSet<XElement> Find_SOSS(Match match, Capture capture)
        {
            HashSet<XElement> set = null;

            foreach (Capture idCapture in match.Groups["IDSelector"].SubcapturesOf(capture))
                Filter_ID(ref set, idCapture.Value.Substring(1));

            foreach (Capture typeCapture in match.Groups["TypeSelector"].SubcapturesOf(capture))
                Filter_Type(ref set, typeCapture.Value);

            foreach (Capture attributeCapture in match.Groups["AttributeSelector"].SubcapturesOf(capture))
            {
                string op, value;
                string name = match.Groups["Identifier"].SubcapturesOf(attributeCapture).First().Value;
                Capture opCap = match.Groups["ComparisonOperator"].SubcapturesOf(attributeCapture).SingleOrDefault();
                if (opCap == null)
                {
                    op = null;
                    value = null;
                }
                else
                {
                    op = opCap.Value;
                    value = match.Groups["AttributeValue"].SubcapturesOf(attributeCapture).Single().Value;
                }
                Filter_Attribute(ref set, name, op, value);
            }

            return set ?? new HashSet<XElement>(RootElement.DescendantsAndSelf());
        }
 private static bool IsParameterCapture(Capture match)
 {
     return match.Value.StartsWith("{") && match.Value.EndsWith("}");
 }
        private FontStyle determineNextStyleFromCapture(Capture capture)
        {
            FontStyle newStyle = FontStyle.Regular;
            if (this.styles.Count > 0)
            {
                newStyle = this.styles.Peek();
            }
            switch (capture.Value)
            {
                case BEGINNING_DEL_TAG:
                    newStyle = newStyle | FontStyle.Strikeout;
                    this.styles.Push(newStyle);
                    break;
                case BEGINNING_EM_TAG:
                    newStyle = newStyle | FontStyle.Italic;
                    this.styles.Push(newStyle);
                    break;
                case BEGINNING_INS_TAG:
                    newStyle = newStyle | FontStyle.Underline;
                    this.styles.Push(newStyle);
                    break;
                case BEGINNING_STRONG_TAG:
                    newStyle = newStyle | FontStyle.Bold;
                    this.styles.Push(newStyle);
                    break;

                case ENDING_DEL_TAG:
                    newStyle = this.styles.Pop() ^ FontStyle.Strikeout;
                    break;
                case ENDING_EM_TAG:
                    newStyle = this.styles.Pop() ^ FontStyle.Italic;
                    break;
                case ENDING_INS_TAG:
                    newStyle = this.styles.Pop() ^ FontStyle.Underline;
                    break;
                case ENDING_STRONG_TAG:
                    newStyle = this.styles.Pop() ^ FontStyle.Bold;
                    break;
            }
            return newStyle;
        }
Beispiel #26
0
        private void AppendCapturedStylesForNestedLanguage(Capture regexCapture,
                                                           int offset,
                                                           string nestedLanguageId,
                                                           ICollection<Scope> capturedStyles)
        {
            ILanguage nestedLanguage = languageRepository.FindById(nestedLanguageId);

            if (nestedLanguage == null)
                throw new InvalidOperationException("The nested language was not found in the language repository.");
            else
            {
                CompiledLanguage nestedCompiledLanguage = languageCompiler.Compile(nestedLanguage);

                Match regexMatch = nestedCompiledLanguage.Regex.Match(regexCapture.Value, 0, regexCapture.Value.Length);

                if (!regexMatch.Success)
                    return;
                else
                {
                    while (regexMatch.Success)
                    {
                        List<Scope> capturedStylesForMatchedFragment = GetCapturedStyles(regexMatch, 0, nestedCompiledLanguage);
                        List<Scope> capturedStyleTree = CreateCapturedStyleTree(capturedStylesForMatchedFragment);

                        foreach (Scope nestedCapturedStyle in capturedStyleTree)
                        {
                            IncreaseCapturedStyleIndicies(capturedStyleTree, offset);
                            capturedStyles.Add(nestedCapturedStyle);
                        }

                        regexMatch = regexMatch.NextMatch();
                    }
                }
            }
        }
Beispiel #27
0
		public void FixtureSetUp ()
		{
			capture = (Capture) Match.Empty.Groups [0];
		}
Beispiel #28
0
 private static Function FindFunc(string text, Capture match)
 {
     var pos = match.Index + match.Length;
     var prototype = match.Value;
     var namePos = match.Index;
     var func = new Function {NamePos = namePos};
     var i = 0;
     while (prototype[i++] != ' ')
     {
     }
     func.Type = i == "function ".Length ? FuncType.Function : FuncType.Procedure;
     while (prototype[i++] == ' ')
     {
     }
     var j = i;
     while (prototype[i] != ' ')
     {
         i++;
     }
     while (!char.IsLetterOrDigit(prototype[i - 1])) i--;
     func.Name = prototype.Substring(j - 1, i - j + 1);
     func.EndPos = new Regex("\\bend\\s+" + func.Name + "\\b").Match(text, pos).Index;
     func.Local = GetLocals(text.Substring(func.NamePos, func.EndPos - func.NamePos)).ToArray();
     var declares =
         new Regex(@"(\bdeclare)((.|\n)+)(begin)((.|\n)+)(end;)").Matches(text.Substring(func.NamePos,
             func.EndPos - func.NamePos));
     foreach (Match declare in declares)
     {
         var localsInDeclare =
             new Regex("(\\s*\\w[\\w\\d_]*\\s*)(,\\s*\\w[\\w\\d_]*\\s*)*:[^=]").Matches(declare.Value);
         foreach (Match localDec in localsInDeclare)
             if (localDec.Value.IndexOf(',') > 0)
                 foreach (var local in localDec.Value.Substring(0, localDec.Value.Length - ": ".Length).Split(','))
                 {
                     for (var k = 0; k < func.Local.Length; k++)
                         if (func.Local[k].Name == local.Trim())
                         {
                             func.Local[k].LocalType = LocalType.DeclareParametr;
                             break;
                         }
                 }
             else
             {
                 for (var k = 0; k < func.Local.Length; k++)
                     if (func.Local[k].Name ==
                         localDec.Value.Substring(0, localDec.Value.Length - ": ".Length).Trim())
                     {
                         func.Local[k].LocalType = LocalType.DeclareParametr;
                         break;
                     }
             }
     }
     return func;
 }
Beispiel #29
0
 private static string UpdateString(string input, Capture group, IDictionary<string, string> lookup)
 {
     var output = input.Remove(group.Index - 1, group.Length + 2);
     return output.Insert(group.Index - 1, lookup[group.Value]);
 }
		private static string GetTypedViewName(Capture view)
		{
			if (view == null || string.IsNullOrEmpty(view.Value))
				return null;
			return view.Value;
		}
        private void AddSubNode(int parentNodeIndex,string caption,Capture matchCapture,int groupIndex,int captureIndex)
        {
            if(InvokeRequired)
            {
                Invoke(new StdAddSubNodeDelegateCapture(AddSubNode),
                    new object[]{parentNodeIndex,
                                    caption,
                                    matchCapture,
                                    groupIndex,
                                    captureIndex});
                return ;
            }

            TreeNode node = Tree.Nodes[parentNodeIndex].Nodes[groupIndex-1];
            node.Nodes.Add(new TreeNode(caption,ICON_CAPTURE,ICON_CAPTURE));
            node.Nodes[captureIndex].Tag=matchCapture;
        }
Beispiel #32
0
 public static IEnumerable<Capture> SubcapturesOf(this Group g, Capture c)
 {
     return g.Captures.Cast<Capture>().Where(x => x.Index >= c.Index && x.Index + x.Length <= c.Index + c.Length);
 }
Beispiel #33
0
 public ElementContent(ElementContent content, Capture capture)
     : this(content, capture.Index, capture.Length)
 {
 }
Beispiel #34
0
 public MatchItem(Capture item)
 {
     Children = new ObservableCollection<MatchItem>();
     Content = item.Value;
 }
Beispiel #35
0
 private static void AppendCapturedMatchesForRegexCapture(Capture regexCapture, string capture,
                                                          ICollection<Scope> capturedScopes)
 {
     capturedScopes.Add(new Scope(capture, regexCapture.Index, regexCapture.Length));
 }
Beispiel #36
0
 private void AppendCapturedStylesForRegexCapture(Capture regexCapture,
                                                  int currentIndex,
                                                  string styleName,
                                                  ICollection<Scope> capturedStyles)
 {
     if (styleName.StartsWith(ScopeName.LanguagePrefix))
     {
         string nestedGrammarId = styleName.Substring(1);
         AppendCapturedStylesForNestedLanguage(regexCapture, regexCapture.Index - currentIndex, nestedGrammarId, capturedStyles);
     }
     else
         capturedStyles.Add(new Scope(styleName, regexCapture.Index - currentIndex, regexCapture.Length));
 }
        public void MatchText()
        {
            SetPending();
            this.Refresh();
            txtTestText.ClearDocumentStyle();
            txtTestText.StartStyling(0);
            txtTestText.SetStyling(txtTestText.TextLength, 0);

            txtTestText.Styles[Style.Default].Size = 12;
            txtTestText.Styles[Style.Default].Font = "Consolas";


            if (this.txtRE.Text == "" || this.txtTestText.Text == "")

            {
                this.lblResultSummary.Text      = "Nothing to match";
                this.lblResultSummary.BackColor = SystemColors.Control;
                return;
            }

            if (_Dirty)
            {
                try
                {
                    // _re = new RegexTools.SafeRegex(Pattern, 500, RegexOptions.Singleline | RegexOptions.ExplicitCapture);
                    _re = new RegexTools.SafeRegex(Clean(Pattern), 500, RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);

                    _Dirty = false;
                }
                catch (Exception ex)
                {
                    SetInfo("Pattern error: " + ex.Message, true);
                    //  ResumeUpdating();
                    return;
                }
            }


            var           groupNames = _re.BaseRegex.GetGroupNames();
            List <Target> targets    = new List <Target>();

            foreach (var groupName in groupNames)
            {
                if (groupName.ToString() != "0")
                {
                    targets.Add(new Target(groupName.ToString()));
                }
            }
            this.lblResultSummary.Visible = true;
            string info = "";

            try
            {
                _matches = _re.Matches(Input);
            }
            catch (Conductor.RegexTools.RegexPerformanceException pex)
            {
                SetInfo("Performance error: " + pex.Message, true);
                return;
            }
            catch (Exception ex)
            {
                SetInfo("Error: " + ex.Message, true);
                return;
            }

            if (_matches.Count == 0)
            {
                info = "No match";
            }
            if (_matches.Count == 1)
            {
                info = "Single match starting at " + _matches[0].Index;
            }
            if (_matches.Count > 1)
            {
                info = _matches.Count.ToString() + " matches";
            }

            info = info + " (" + _re.LastMatchExecutionTime.Value + " ms)";

            SetInfo(info, _matches.Count == 0);
            _namedCaptures.Clear();
            int colorIndex = 0;

            for (int matchIndex = 0; matchIndex < _matches.Count; matchIndex++)
            {
                //   colorIndex++;
                Match match = _matches[matchIndex];
                //   List<Capture> currentCaptures = new List<Capture>();


                foreach (Target target in targets)
                {
                    Group g = match.Groups[target.name];

                    if (g.Index != 0)
                    {
                        Capture capture = new Capture(target.name);
                        capture.value    = g.Value;
                        capture.position = g.Index;
                        capture.length   = g.Length;
                        _namedCaptures.Add(capture);
                    }
                    //  currentCaptures.Add(capture);
                }
                // allCap.Add(currentCaptures);

                for (int groupIndex = 0; groupIndex < match.Groups.Count; groupIndex++)
                {
                    colorIndex++;
                    Group group = match.Groups[groupIndex];



                    for (int captureIndex = 0; captureIndex < group.Captures.Count; captureIndex++)
                    {
                        System.Text.RegularExpressions.Capture capture = group.Captures[captureIndex];

                        //    System.Diagnostics.Debug.WriteLine(matchIndex.ToString() + ":" + groupIndex.ToString() + ":" + captureIndex.ToString() + "  " + match.Index.ToString() + ":" + group.Index.ToString() + ":" +
                        // capture.Index.ToString() + " '" + capture.Value + "'" + " ColorIndex:" + colorIndex.ToString());
                        colorIndex = colorIndex++ % STYLE_MAX;
                        if (colorIndex == 0)
                        {
                            colorIndex = 1;
                        }
                        if (false)
                        {
                            // if (colorIndex > 30) return;
                            int start = capture.Index;
                            txtTestText.StartStyling(start);
                            txtTestText.Styles[colorIndex].BackColor = Conductor.GUI.ColorHelper.GetColor(colorIndex);
                            int length = capture.Length;
                            txtTestText.SetStyling(length, colorIndex);
                        }
                    }
                }
            }

            colorIndex = -1;
            int styleIndex;

            Capture firstCapture = (_namedCaptures.Count > 0) ? _namedCaptures[0] : null;

            foreach (var capture in _namedCaptures)
            {
                colorIndex = (colorIndex + 1) % STYLE_MAX;
                styleIndex = colorIndex + 1;
                if (capture.position != 0)
                {
                    int start = capture.position;
                    txtTestText.StartStyling(start);
                    txtTestText.Styles[styleIndex].BackColor = Conductor.GUI.ColorHelper.GetColor(colorIndex);
                    int length = capture.length;
                    txtTestText.SetStyling(length, styleIndex);
                }
            }

            if (firstCapture != null)
            {
                int  position = firstCapture.position;
                Line line     = this.txtTestText.Lines[this.txtTestText.LineFromPosition(position)];
                //    this.txtTestText.ScrollRange(line.Position, line.Position);
            }

            this.gridCaptures.DataSource = _namedCaptures;
            this.gridCaptures.Grid.Columns["position"].Visible = false;
            this.gridCaptures.Grid.Columns["length"].Visible   = false;
            //ResumeUpdating();
        }
Beispiel #38
0
		private TemplateElement CreateAttributeList(Capture capture)
		{
            TemplateElement result = new TemplateElement(this.Document, TemplateElementTypes.AttributeList, capture.Index, capture.Length, null);

			return result;
		}
 private static string GetStringBetweenCaptures (Capture current, Capture next, string str, int termPos)
 {
     int lastIndex = current.Index + current.Length;
     string strBetween = next != null
         ? str.Substring(lastIndex, next.Index - lastIndex)
         : str.Substring(lastIndex, termPos - lastIndex);
     return strBetween;
 }