RegEx.Substring
---------------

Queries a substring.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [RegEx](component_RegEx.md) | [4.4](newinversion44.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "RegEx.Substring"; RegExRef; Index ) 

**MBS**( **"RegEx.Substring";** /\* Queries a substring. \*/  
**$RegExRef**; /\* The reference number for the regular expression returned from [RegEx.Compile](RegExCompile.md).e.g. $regex \*/   
**$Index**) /\* The index for the substring.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| RegExRef | The reference number for the regular expression returned from [RegEx.Compile](RegExCompile.md). | $regex |
| Index | The index for the substring. | 0 |

### Result

Returns text or error.

### Description

Queries a substring.  
Index 0 gives whole match and index from 1 to [RegEx.CaptureCount](RegExCaptureCount.md) gives substrings matched.  
### Examples

Find seller ID in an URL:

 Let (\[  
pattern = "^http.\*\\?.\*&amp;seller=(.\*)$";  
text = "https://www.example.com.com/gp/aag/main/ref=olp\_merch\_name\_2?ie=UTF8&amp;astn=B8J070KLDO&amp;isFulfilled=1&amp;seller=A2XKMLD9HIY1T";  
  
regex = MBS ( "[RegEx.Compile](RegExCompile.md)"; pattern; 512+1 );  
r = MBS ( "[RegEx.Execute](RegExExecute.md)"; regex; text; 0 );  
r = MBS ( "RegEx.Substring"; regex; 1 );  
f = MBS ( "[RegEx.Release](RegExRelease.md)"; regex )  
\] ; r )  
### See also

- [RegEx.CaptureCount](RegExCaptureCount.md)
- [RegEx.Compile](RegExCompile.md)
- [RegEx.Execute](RegExExecute.md)
- [RegEx.Release](RegExRelease.md)
- [RegEx.Results](RegExResults.md)
- [RegEx.SubstringList](RegExSubstringList.md)

### Example Databases

- [RegEx/RegEx](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/RegEx/RegEx.shtml#2ScriptAnchor_)

This function checks for a license.

Created 26th October 2014 , last changed 26th April 2023

  
[RegEx.Study](RegExStudy.md) - [RegEx.SubstringList](RegExSubstringList.md)

[HTML Version](RegExSubstring.shtml)