Skip to main content

Match.text

textgroupdefault

Group: Metadata

Documentation

Gets the Text matched by the group with the provided identifier, or a default value if the group did not participate in the match. If no such group exists for the provided identifier, a No_Such_Group is returned.

Arguments

  • group: The integer index or name of that group.

Remarks

The Full Match

The group with index 0 is always the full match of the pattern.

Named Groups by Index

If the regex contained named groups, these may also be accessed by index based on their position in the pattern.

Note that it is possible for a group to "not participate in the match", for example with a disjunction. In the example below, the "(d)" group does not participate -- it neither matches nor fails.

"ab((c)|(d))".find "abc"

In this case, the group id for "(d)", which is 3, is a valid group id and (Regex.lookup_group 3) will return 3. If the caller tries to get group 3, Match.text will return the default value.