Share via


Groups Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets a collection of groups matched by the regular expression.

Namespace:  System.Text.RegularExpressions
Assembly:  System.Text.RegularExpressions (in System.Text.RegularExpressions.dll)

Syntax

'Declaration
Public Overridable ReadOnly Property Groups As GroupCollection
public virtual GroupCollection Groups { get; }
public:
virtual property GroupCollection^ Groups {
    GroupCollection^ get ();
}
abstract Groups : GroupCollection with get
override Groups : GroupCollection with get
function get Groups () : GroupCollection

Property Value

Type: System.Text.RegularExpressions. . :: . .GroupCollection
The character groups matched by the pattern.

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. 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 GroupCollection object that is returned by the Groups property.

The GroupCollection object returned by the Match..::..Groups property always has at least one member. If the regular expression engine cannot find any matches in a particular input string, the Group..::..Success property of the single Group object in the collection is set to false and the Group object's Value property is set to String..::..Empty. If the regular expression engine can find a match, the first element of the GroupCollection object returned by the Groups property contains a string that matches the entire regular expression pattern.

.NET Framework Security

See Also

Reference

Match Class

System.Text.RegularExpressions Namespace