Class

# RegExMatch

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to extract the matched string when doing a search with regular expressions.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                | Type                               | Read-Only | Shared |
|-----------------------------------------------------|------------------------------------|-----------|--------|
| `SubExpressionCount<regexmatch.subexpressioncount>` | `Integer</api/data_types/integer>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                  | Parameters                                                 | Returns                            | Shared |
|-------------------------------------------------------|------------------------------------------------------------|------------------------------------|--------|
| `Replace<regexmatch.replace>`                         | \[ReplacementPattern As `String</api/data_types/string>`\] | `String</api/data_types/string>`   |        |
| `SubExpressionStartB<regexmatch.subexpressionstartb>` | matchNumber As `Integer</api/data_types/integer>`          | `Integer</api/data_types/integer>` |        |
| `SubExpressionString<regexmatch.subexpressionstring>` | matchNumer As `Integer</api/data_types/integer>`           | `String</api/data_types/string>`   |        |

## Property descriptions

<div id="regexmatch.subexpressioncount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

RegExMatch.SubExpressionCount

**SubExpressionCount** As `Integer</api/data_types/integer>`

> Number of SubExpressions that are available with the search just performed.
>
> Regular Expressions support both `\number` and `$number` syntax for SubExpressions.
>
> SubExpressions allow replacement of parts of the pattern.
>
> This property is read-only.

## Method descriptions

<div id="regexmatch.replace">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

RegExMatch.Replace

**Replace**(\[ReplacementPattern As `String</api/data_types/string>`\]) As `String</api/data_types/string>`

> Substitutes the matched result in a manner specified by the given *ReplacementPattern*.
>
> If no *ReplacementPattern* is specified, it uses the ReplacementPattern which was specified in the `RegEx</api/text/regular_expressions/regex>` object at the time of the search.

<div id="regexmatch.subexpressionstartb">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

RegExMatch.SubExpressionStartB

**SubExpressionStartB**(matchNumber As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

> Returns the starting byte offset of the SubExpression given by *matchNumber*.
>
> To convert this byte offset into a 1-based character position (for use with String functions such as Mid and Left), use this code:
>
> ``` xojo
> Var s As String = theString
>
> characterPosition = s.LeftBytes(aRegExMatch.SubExpressionStartB(matchNumber)).Length + 1
> ```

<div id="regexmatch.subexpressionstring">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

RegExMatch.SubExpressionString

**SubExpressionString**(matchNumer As `Integer</api/data_types/integer>`) As `String</api/data_types/string>`

> Returns the SubExpression as a `String</api/data_types/string>` for the passed *matchNumber*.
>
> 0 returns the entire MatchString (the implicit 0th SubExpression), and 1 is the first real SubExpression.

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `RegEx</api/text/regular_expressions/regex>` class.

</div>
