Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt

Returns the number of groups found in the current SearchMatch. Regular expression groups are created by adding parentheses to the regular expression. This method should always return at least 1.

Signature
C#
C#
<table class="diff-macro"><thead><tr><th class="diff-macro-title">unmigrated-wiki-markup</th></tr></thead><tbody><tr><td class="diff-macro-body"><pre>
 public int GroupCount{ get; }
</pre></td></tr></tbody></table>
Signature
vb.net
vb.net

<p>Public ReadOnly Property GroupCount() As Integer</p>
Example
 
Code Block
csharp
csharp
titleC#
            WordApplication app = new WordApplication();
          Document doc = app.Open(@"C:\somedoc.doc");
          IEnumerator searcherator = doc.Search("\s\d\d\d-?\d\d-?\d\d\d\d\s");
          while (searcherator.MoveNext())
          {
               SearchMatch match = (SearchMatch)searcherator.Current;
               int numMatchGroups = match.GroupCount;
               match.Element.Delete();
          }
        
Code Block
vb.net
vb.net
titlevb.net
            Dim app As New WordApplication()
          Dim doc As Document = app.Open("C:\somedoc.doc")
          Dim searcherator As IEnumerator = doc.Search("\s\d\d\d-?\d\d-?\d\d\d\d\s")
          While searcherator.MoveNext()
               Dim match As SearchMatch = searcherator.Current
               Dim numMatchGroups As Integer = match.GroupCount
               match.Element.Delete()
          End While
        
Example