Matcher.Group Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Group(String) |
Returns the input subsequence captured by the given named-capturing group during the previous match operation. |
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(String)
Returns the input subsequence captured by the given named-capturing group during the previous match operation.
[Android.Runtime.Register("group", "(Ljava/lang/String;)Ljava/lang/String;", "", ApiSince=26)]
public string? Group (string name);
[<Android.Runtime.Register("group", "(Ljava/lang/String;)Ljava/lang/String;", "", ApiSince=26)>]
member this.Group : string -> string
Parameters
- name
- String
The name of a named-capturing group in this matcher's pattern
Returns
The (possibly empty) subsequence captured by the named 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 named-capturing group during the previous match operation.
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.
Added in 1.7.
Java documentation for java.util.regex.Matcher.group(java.lang.String)
.
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()
Returns the input subsequence matched by the previous match.
[Android.Runtime.Register("group", "()Ljava/lang/String;", "")]
public string Group ();
[<Android.Runtime.Register("group", "()Ljava/lang/String;", "")>]
abstract member Group : unit -> string
override this.Group : unit -> string
Returns
The (possibly empty) subsequence matched by the previous match, in string form
Implements
- Attributes
Exceptions
if no successful match has been made.
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(),
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.Matcher.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;", "")]
public string? Group (int group);
[<Android.Runtime.Register("group", "(I)Ljava/lang/String;", "")>]
abstract member Group : int -> string
override this.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
Implements
- Attributes
Exceptions
if no successful match has been made.
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),
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.Matcher.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.