IMatchResult.Group Method

Definition

Overloads

Group()

Returns the input subsequence matched by the previous match.

Group(Int32)

Returns the input subsequence captured by the given group during the previous match operation.

Group()

Returns the input subsequence matched by the previous match.

[Android.Runtime.Register("group", "()Ljava/lang/String;", "GetGroupHandler:Java.Util.Regex.IMatchResultInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public string? Group ();
[<Android.Runtime.Register("group", "()Ljava/lang/String;", "GetGroupHandler:Java.Util.Regex.IMatchResultInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member Group : unit -> string

Returns

The (possibly empty) subsequence matched by the previous match, in string form

Attributes

Remarks

Returns the input subsequence matched by the previous match.

For a matcher m with input sequence s, the expressions m.group() and s.substring(m.start(),&nbsp;m.end()) are equivalent.

Note that some patterns, for example a*, match the empty string. This method will return the empty string when the pattern successfully matches the empty string in the input.

Java documentation for java.util.regex.MatchResult.group().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Group(Int32)

Returns the input subsequence captured by the given group during the previous match operation.

[Android.Runtime.Register("group", "(I)Ljava/lang/String;", "GetGroup_IHandler:Java.Util.Regex.IMatchResultInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public string? Group (int group);
[<Android.Runtime.Register("group", "(I)Ljava/lang/String;", "GetGroup_IHandler:Java.Util.Regex.IMatchResultInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member Group : int -> string

Parameters

group
Int32

The index of a capturing group in this matcher's pattern

Returns

The (possibly empty) subsequence captured by the group during the previous match, or null if the group failed to match part of the input

Attributes

Remarks

Returns the input subsequence captured by the given group during the previous match operation.

For a matcher m, input sequence s, and group index g, the expressions m.group(g) and s.substring(m.start(g),&nbsp;m.end(g)) are equivalent.

Capturing groups are indexed from left to right, starting at one. Group zero denotes the entire pattern, so the expression m.group(0) is equivalent to m.group().

If the match was successful but the group specified failed to match any part of the input sequence, then null is returned. Note that some groups, for example (a*), match the empty string. This method will return the empty string when such a group successfully matches the empty string in the input.

Java documentation for java.util.regex.MatchResult.group(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to