-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Match.xml
443 lines (392 loc) · 33.5 KB
/
Match.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<Type Name="Match" FullName="System.Text.RegularExpressions.Match">
<TypeSignature Language="C#" Value="public class Match : System.Text.RegularExpressions.Group" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit Match extends System.Text.RegularExpressions.Group" FrameworkAlternate="dotnet-uwp-10.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netstandard-1.0;netstandard-1.1;netstandard-1.2;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<TypeSignature Language="DocId" Value="T:System.Text.RegularExpressions.Match" />
<TypeSignature Language="VB.NET" Value="Public Class Match
Inherits Group" />
<TypeSignature Language="F#" Value="type Match = class
 inherit Group" />
<TypeSignature Language="C++ CLI" Value="public ref class Match : System::Text::RegularExpressions::Group" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi serializable beforefieldinit Match extends System.Text.RegularExpressions.Group" FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<AssemblyInfo>
<AssemblyName>System.Text.RegularExpressions</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="System" FromVersion="4.0.0.0" To="System.Text.RegularExpressions" ToVersion="0.0.0.0" FrameworkAlternate="dotnet-uwp-10.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.RegularExpressions" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.RegularExpressions" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.RegularExpressions" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.RegularExpressions" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.RegularExpressions" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Text.RegularExpressions.Group</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(0)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(0)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(1)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(1)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Serializable]</AttributeName>
<AttributeName Language="F#">[<System.Serializable>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents the results from a single regular expression match.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Text.RegularExpressions.Match> object is immutable and has no public constructor. An instance of the <xref:System.Text.RegularExpressions.Match> class is returned by the <xref:System.Text.RegularExpressions.Regex.Match%2A?displayProperty=nameWithType> method and represents the first pattern match in a string. Subsequent matches are represented by <xref:System.Text.RegularExpressions.Match> objects returned by the <xref:System.Text.RegularExpressions.Match.NextMatch%2A?displayProperty=nameWithType> method. In addition, a <xref:System.Text.RegularExpressions.MatchCollection> object that consists of zero, one, or more <xref:System.Text.RegularExpressions.Match> objects is returned by the <xref:System.Text.RegularExpressions.Regex.Matches%2A?displayProperty=nameWithType> method.
If the <xref:System.Text.RegularExpressions.Regex.Matches%2A?displayProperty=nameWithType> method fails to match a regular expression pattern in an input string, it returns an empty <xref:System.Text.RegularExpressions.MatchCollection> object. You can then use a `foreach` construct in C# or a `For Each` construct in Visual Basic to iterate the collection.
If the <xref:System.Text.RegularExpressions.Regex.Match%2A?displayProperty=nameWithType> method fails to match the regular expression pattern, it returns a <xref:System.Text.RegularExpressions.Match> object that is equal to <xref:System.Text.RegularExpressions.Match.Empty%2A?displayProperty=nameWithType>. You can use the <xref:System.Text.RegularExpressions.Group.Success%2A> property to determine whether the match was successful. The following example provides an illustration.
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Overview/Match1.cs" interactive="try-dotnet-method" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match1.vb" id="Snippet1":::
If a pattern match is successful, the <xref:System.Text.RegularExpressions.Capture.Value%2A> property contains the matched substring, the <xref:System.Text.RegularExpressions.Capture.Index%2A> property indicates the zero-based starting position of the matched substring in the input string, and the <xref:System.Text.RegularExpressions.Capture.Length%2A> property indicates the length of matched substring in the input string.
Because a single match can involve multiple capturing groups, <xref:System.Text.RegularExpressions.Match> has a <xref:System.Text.RegularExpressions.Match.Groups%2A> property that returns the <xref:System.Text.RegularExpressions.GroupCollection>. The <xref:System.Text.RegularExpressions.Match> instance itself is equivalent to the first object in the collection, at `Match.Groups[0]` (`Match.Groups(0)` in Visual Basic), which represents the entire match. You can access the captured groups in a match in the following ways:
- You can iterate the members of the <xref:System.Text.RegularExpressions.GroupCollection> object by using a `foreach` (C#) or `For Each` (Visual Basic) construct.
- You can use the <xref:System.Text.RegularExpressions.GroupCollection.Item%28System.Int32%29?displayProperty=nameWithType> property to retrieve groups by the number of the capturing group. Note that you can determine which numbered groups are present in a regular expression by calling the instance <xref:System.Text.RegularExpressions.Regex.GetGroupNumbers%2A?displayProperty=nameWithType> method.
- You can use the <xref:System.Text.RegularExpressions.GroupCollection.Item%28System.String%29?displayProperty=nameWithType> property to retrieve groups by the name of the capturing group. Note that you can determine which named groups are present in a regular expression by calling the instance <xref:System.Text.RegularExpressions.Regex.GetGroupNames?displayProperty=nameWithType> method.
## Examples
The following examples use the regular expression `Console\.Write(Line)?`. The regular expression is interpreted as follows:
|||
|-|-|
|Console\\.Write|Match the string "Console.Write". Note that the "." character is escaped so that it is interpreted as a literal period rather than as a wildcard that matches any character.|
|(Line)?|Match zero or one occurrence of the string "Line".|
**Example 1**
The following example calls the <xref:System.Text.RegularExpressions.Regex.Matches%28System.String%2CSystem.String%29?displayProperty=nameWithType> method to retrieve all pattern matches in an input string. It then iterates the <xref:System.Text.RegularExpressions.Match> objects in the returned <xref:System.Text.RegularExpressions.MatchCollection> object to display information about each match.
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Overview/Match2.cs" interactive="try-dotnet" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match2.vb" id="Snippet2":::
**Example 2**
The following example calls the <xref:System.Text.RegularExpressions.Regex.Match%28System.String%2CSystem.String%29> and <xref:System.Text.RegularExpressions.Match.NextMatch%2A> methods to retrieve one match at a time.
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Overview/Match3.cs" interactive="try-dotnet" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.RegularExpressions.Match.Class/vb/Match3.vb" id="Snippet3":::
]]></format>
</remarks>
<altmember cref="T:System.Text.RegularExpressions.MatchCollection" />
<altmember cref="T:System.Text.RegularExpressions.Regex" />
</Docs>
<Members>
<Member MemberName="Empty">
<MemberSignature Language="C#" Value="public static System.Text.RegularExpressions.Match Empty { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Text.RegularExpressions.Match Empty" />
<MemberSignature Language="DocId" Value="P:System.Text.RegularExpressions.Match.Empty" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property Empty As Match" />
<MemberSignature Language="F#" Value="static member Empty : System.Text.RegularExpressions.Match" Usage="System.Text.RegularExpressions.Match.Empty" />
<MemberSignature Language="C++ CLI" Value="public:
 static property System::Text::RegularExpressions::Match ^ Empty { System::Text::RegularExpressions::Match ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.RegularExpressions</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Text.RegularExpressions.Match</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the empty group. All failed matches return this empty match.</summary>
<value>An empty match.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property should not be used to determine if a match is successful. Instead, use the `Match.Success` property (which is inherited from <xref:System.Text.RegularExpressions.Group.Success%2A?displayProperty=nameWithType>).
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Groups">
<MemberSignature Language="C#" Value="public virtual System.Text.RegularExpressions.GroupCollection Groups { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Text.RegularExpressions.GroupCollection Groups" />
<MemberSignature Language="DocId" Value="P:System.Text.RegularExpressions.Match.Groups" />
<MemberSignature Language="VB.NET" Value="Public Overridable ReadOnly Property Groups As GroupCollection" />
<MemberSignature Language="F#" Value="member this.Groups : System.Text.RegularExpressions.GroupCollection" Usage="System.Text.RegularExpressions.Match.Groups" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual property System::Text::RegularExpressions::GroupCollection ^ Groups { System::Text::RegularExpressions::GroupCollection ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.RegularExpressions</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Text.RegularExpressions.GroupCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a collection of groups matched by the regular expression.</summary>
<value>The character groups matched by the pattern.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A regular expression pattern can include subexpressions, which are defined by enclosing a portion of the regular expression pattern in parentheses. Every such subexpression forms a group. The <xref:System.Text.RegularExpressions.Match.Groups%2A> property provides access to information about those subexpression matches. For example, the regular expression pattern `(\d{3})-(\d{3}-\d{4})`, which matches North American telephone numbers, has two subexpressions. The first consists of the area code, which composes the first three digits of the telephone number. This group is captured by the first portion of the regular expression, `(\d{3})`. The second consists of the individual telephone number, which composes the last seven digits of the telephone number. This group is captured by the second portion of the regular expression, `(\d{3}-\d{4})`. These two groups can then be retrieved from the <xref:System.Text.RegularExpressions.GroupCollection> object that is returned by the <xref:System.Text.RegularExpressions.Match.Groups%2A> property, as the following example shows.
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Groups/groups1.cs" interactive="try-dotnet" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.match.groups/vb/groups1.vb" id="Snippet1":::
The <xref:System.Text.RegularExpressions.GroupCollection> object returned by the <xref:System.Text.RegularExpressions.Match.Groups%2A?displayProperty=nameWithType> property is a zero-based collection object that always has at least one member. If the regular expression engine cannot find any matches in a particular input string, the <xref:System.Text.RegularExpressions.Group.Success%2A?displayProperty=nameWithType> property of the single <xref:System.Text.RegularExpressions.Group> object in the collection (the object at index 0) is set to `false` and the <xref:System.Text.RegularExpressions.Group> object's <xref:System.Text.RegularExpressions.Capture.Value%2A> property is set to <xref:System.String.Empty?displayProperty=nameWithType>. If the regular expression engine can find a match, the first element of the <xref:System.Text.RegularExpressions.GroupCollection> object (the element at index 0) returned by the <xref:System.Text.RegularExpressions.Match.Groups%2A> property contains a string that matches the entire regular expression pattern. Each subsequent element, from index one upward, represents a captured group, if the regular expression includes capturing groups. For more information, see the "Grouping Constructs and Regular Expression Objects" section of the [Grouping Constructs](/dotnet/standard/base-types/grouping-constructs-in-regular-expressions) article.
## Examples
The following example attempts to match a regular expression pattern against a sample string. The example uses the <xref:System.Text.RegularExpressions.Match.Groups%2A> property to store information that is retrieved by the match for display to the console.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp" id="Snippet8":::
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Groups/snippet8.cs" interactive="try-dotnet" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/regex match, nextmatch, groups, captures/vb/snippet8.vb" id="Snippet8":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="NextMatch">
<MemberSignature Language="C#" Value="public System.Text.RegularExpressions.Match NextMatch ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Text.RegularExpressions.Match NextMatch() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.RegularExpressions.Match.NextMatch" />
<MemberSignature Language="VB.NET" Value="Public Function NextMatch () As Match" />
<MemberSignature Language="F#" Value="member this.NextMatch : unit -> System.Text.RegularExpressions.Match" Usage="match.NextMatch " />
<MemberSignature Language="C++ CLI" Value="public:
 System::Text::RegularExpressions::Match ^ NextMatch();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.RegularExpressions</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Text.RegularExpressions.Match</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns a new <see cref="T:System.Text.RegularExpressions.Match" /> object with the results for the next match, starting at the position at which the last match ended (at the character after the last matched character).</summary>
<returns>The next regular expression match.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is similar to calling <xref:System.Text.RegularExpressions.Regex.Match%28System.String%2CSystem.Int32%29?displayProperty=nameWithType> again and passing (`Index+Length`) as the new starting position.
> [!NOTE]
> This method does not modify the current instance. Instead, it returns a new <xref:System.Text.RegularExpressions.Match> object that contains information about the next match.
Attempting to retrieve the next match may throw a <xref:System.Text.RegularExpressions.RegexMatchTimeoutException> if a time-out value for matching operations is in effect and the attempt to find the next match exceeds that time-out interval.
## Examples
The following example uses the <xref:System.Text.RegularExpressions.Match.NextMatch%2A> method to capture regular expression matches beyond the first match.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp" id="Snippet8":::
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Groups/snippet8.cs" interactive="try-dotnet" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/regex match, nextmatch, groups, captures/vb/snippet8.vb" id="Snippet8":::
]]></format>
</remarks>
<exception cref="T:System.Text.RegularExpressions.RegexMatchTimeoutException">A time-out occurred.</exception>
<block subset="none" type="usage">
<para>When a match attempt is repeated by calling the <see cref="M:System.Text.RegularExpressions.Match.NextMatch" /> method, the regular expression engine gives empty matches special treatment. Usually, <see cref="M:System.Text.RegularExpressions.Match.NextMatch" /> begins the search for the next match exactly where the previous match left off. However, after an empty match, the <see cref="M:System.Text.RegularExpressions.Match.NextMatch" /> method advances by one character before trying the next match. This behavior guarantees that the regular expression engine will progress through the string. Otherwise, because an empty match does not result in any forward movement, the next match would start in exactly the same place as the previous match, and it would match the same empty string repeatedly.
The following example provides an illustration. The regular expression pattern <c>a*</c> searches for zero or more occurrences of the letter "a" in the string "abaabb". As the output from the example shows, the search finds six matches. The first match attempt finds the first "a". The second match starts exactly where the first match ends, before the first b; it finds zero occurrences of "a" and returns an empty string. The third match does not begin exactly where the second match ended, because the second match returned an empty string. Instead, it begins one character later, after the first "b". The third match finds two occurrences of "a" and returns "aa". The fourth match attempt begins where the third match ended, before the second "b", and returns an empty string. The fifth match attempt again advances one character so that it begins before the third "b" and returns an empty string. The sixth match begins after the last "b" and returns an empty string again.
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/NextMatch/nextmatch1.cs" interactive="try-dotnet" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.match.nextmatch/vb/nextmatch1.vb" id="Snippet1":::</para>
</block>
</Docs>
</Member>
<Member MemberName="Result">
<MemberSignature Language="C#" Value="public virtual string Result (string replacement);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance string Result(string replacement) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.RegularExpressions.Match.Result(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Overridable Function Result (replacement As String) As String" />
<MemberSignature Language="F#" Value="abstract member Result : string -> string
override this.Result : string -> string" Usage="match.Result replacement" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual System::String ^ Result(System::String ^ replacement);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.RegularExpressions</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="replacement" Type="System.String" />
</Parameters>
<Docs>
<param name="replacement">The replacement pattern to use.</param>
<summary>Returns the expansion of the specified replacement pattern.</summary>
<returns>The expanded version of the <paramref name="replacement" /> parameter.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Whereas the <xref:System.Text.RegularExpressions.Regex.Replace%2A?displayProperty=nameWithType> method replaces all matches in an input string with a specified replacement pattern, the <xref:System.Text.RegularExpressions.Match.Result%2A> method replaces a single match with a specified replacement pattern. Because it operates on an individual match, it is also possible to perform processing on the matched string before you call the <xref:System.Text.RegularExpressions.Match.Result%2A> method.
The `replacement` parameter is a standard regular expression replacement pattern. It can consist of literal characters and regular expression substitutions. For more information, see [Substitutions](/dotnet/standard/base-types/substitutions-in-regular-expressions).
## Examples
The following example replaces the hyphens that begin and end a parenthetical expression with parentheses.
:::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Result/result1.cs" interactive="try-dotnet" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.match.result/vb/result1.vb" id="Snippet1":::
The regular expression pattern `--(.+?)--` is interpreted as shown in the following table.
|Pattern|Description|
|-------------|-----------------|
|`--`|Match two hyphens.|
|`(.+?)`|Match any character one or more times, but as few times as possible. This is the first capturing group.|
|`--`|Match two hyphens.|
Note that the regular expression pattern `--(.+?)--` uses the lazy quantifier `+?`. If the greedy quantifier `+` were used instead, the regular expression engine would find only a single match in the input string.
The replacement string `($1)` replaces the match with the first captured group, which is enclosed in parentheses.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="replacement" /> is <see langword="null" />.</exception>
<exception cref="T:System.NotSupportedException">Expansion is not allowed for this pattern.</exception>
<altmember cref="M:System.Text.RegularExpressions.Regex.Replace(System.String,System.String)" />
<related type="Article" href="/dotnet/standard/base-types/substitutions-in-regular-expressions">Substitutions in Regular Expressions</related>
</Docs>
</Member>
<Member MemberName="Synchronized">
<MemberSignature Language="C#" Value="public static System.Text.RegularExpressions.Match Synchronized (System.Text.RegularExpressions.Match inner);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Text.RegularExpressions.Match Synchronized(class System.Text.RegularExpressions.Match inner) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.RegularExpressions.Match.Synchronized(System.Text.RegularExpressions.Match)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Synchronized (inner As Match) As Match" />
<MemberSignature Language="F#" Value="static member Synchronized : System.Text.RegularExpressions.Match -> System.Text.RegularExpressions.Match" Usage="System.Text.RegularExpressions.Match.Synchronized inner" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Text::RegularExpressions::Match ^ Synchronized(System::Text::RegularExpressions::Match ^ inner);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Text.RegularExpressions</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Text.RegularExpressions.Match</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="inner" Type="System.Text.RegularExpressions.Match" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.0;netstandard-2.1;netcore-3.1;net-5.0;net-6.0;net-7.0;netframework-4.8.1;net-8.0;net-9.0" />
</Parameters>
<Docs>
<param name="inner">A regular expression match equivalent to the one expected.</param>
<summary>Returns a <see cref="T:System.Text.RegularExpressions.Match" /> instance equivalent to the one supplied that is suitable to share between multiple threads.</summary>
<returns>A regular expression match that is suitable to share between multiple threads.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="inner" /> is <see langword="null" />.</exception>
</Docs>
</Member>
</Members>
</Type>