---
id: object/codeunit/3960
type: object
title: Codeunit 3960 "Regex"
summary: Codeunit 3960 "Regex" in System Application (System.Utilities). 47 public procedures. Present since at least BC23, still in BC30.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: null
  last_changed: null
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: ca9ed41ae726a50ab78a2409f722667cc809bf6ee08947cee064277246023f09
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Regex/src/Regex.Codeunit.al
    title: src/System Application/App/Regex/src/Regex.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 3960
name: Regex
namespace: System.Utilities
app: System Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in: []
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 47
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 1
  called_by: 32
  implements: 0
---

# Codeunit 3960 "Regex"

> Codeunit 3960 "Regex" in System Application (System.Utilities). 47 public procedures. Present since at least BC23, still in BC30.

System Application · System.Utilities · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Regex/src/Regex.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Public |

## Procedures

- `Regex(Pattern: Text)`: Initializes a new instance of the Regex class for the specified regular expression.
- `Regex(Pattern: Text; var RegexOptions: Record "Regex Options")`: Initializes a new instance of the Regex class for the specified regular expression, with options that modify the pattern.
- `GetCacheSize(): Integer`: Gets the maximum number of entries in the current static cache of compiled regular expressions.
- `SetCacheSize(CacheSize: Integer)`: Sets the maximum number of entries in the current static cache of compiled regular expressions.
- `GetGroupNames(var GroupNames: List of [Text])`: Gets an array of capturing group names for the regular expression.
- `GetGroupNumbers(var GroupNumbers: List of [Integer])`: Gets an array of capturing group numbers that correspond to group names in an array.
- `GroupNameFromNumber(Number: Integer): Text`: Gets the group name that corresponds to the specified group number.
- `GroupNumberFromName(Name: Text): Integer`: Gets the group number that corresponds to the specified group name.
- `IsMatch(Input: Text; Pattern: Text; StartAt: Integer): Boolean`: Indicates whether the regular expression finds a match in the input string, beginning at the specified starting position in the string.
- `IsMatch(Input: Text; StartAt: Integer): Boolean`: Indicates whether the regular expression specified in the Regex constructor finds a match in the input string, beginning at the specified starting position in the string.
- `IsMatch(Input: Text; Pattern: Text; StartAt: Integer; var RegexOptions: Record "Regex Options"): Boolean`: Indicates whether the regular expression finds a match in the input string, beginning at the specified starting position in the string.
- `IsMatch(Input: Text; Pattern: Text): Boolean`: Indicates whether the regular expression finds a match in the input string.
- `IsMatch(Input: Text): Boolean`: Indicates whether the regular expression specified in the Regex constructor finds a match in the input string.
- `IsMatch(Input: Text; Pattern: Text; var RegexOptions: Record "Regex Options"): Boolean`: Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options.
- `Match(Input: Text; Pattern: Text; StartAt: Integer; var Matches: Record Matches)`: Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.
- `Match(Input: Text; StartAt: Integer; var Matches: Record Matches)`: Searches the input string for the first occurrence of a regular expression specified in the Regex constructor, beginning at the specified starting position in the string.
- `Match(Input: Text; Pattern: Text; StartAt: Integer; var RegexOptions: Record "Regex Options"; var Matches: Record Matches)`: Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.
- `Match(Input: Text; Pattern: Text; StartAt: Integer; Length: Integer; var Matches: Record Matches)`: Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position and searching only the specified number of characters.
- `Match(Input: Text; StartAt: Integer; Length: Integer; var Matches: Record Matches)`: Searches the input string for the first occurrence of a regular expression specified in the Regex constructor, beginning at the specified starting position and searching only the specified number of characters.
- `Match(Input: Text; Pattern: Text; StartAt: Integer; Length: Integer; var RegexOptions: Record "Regex Options"; var Matches: Record Matches)`: Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position and searching only the specified number of characters.
- `Match(Input: Text; Pattern: Text; var Matches: Record Matches)`: Searches the input string for the first occurrence of the specified regular expression, using the specified matching options.
- `Match(Input: Text; var Matches: Record Matches)`: Searches the input string for the first occurrence of the specified regular expression specified in the Regex constructor, using the specified matching options.
- `Match(Input: Text; Pattern: Text; var RegexOptions: Record "Regex Options"; var Matches: Record Matches)`: Searches the input string for the first occurrence of the specified regular expression, using the specified matching options.
- `Replace(Input: Text; Pattern: Text; Replacement: Text; Count: Integer): Text`: Replaces strings that match a regular expression pattern with a specified replacement string.
- `Replace(Input: Text; Replacement: Text; Count: Integer): Text`: Replaces strings that match a regular expression pattern specified in the Regex constructor with a specified replacement string.
- `Replace(Input: Text; Pattern: Text; Replacement: Text; Count: Integer; var RegexOptions: Record "Regex Options"): Text`: Replaces strings that match a regular expression pattern with a specified replacement string.
- `Replace(Input: Text; Pattern: Text; Replacement: Text; Count: Integer; StartAt: Integer): Text`: In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.
- `Replace(Input: Text; Replacement: Text; Count: Integer; StartAt: Integer): Text`: In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern specified in the Regex constructor with a specified replacement string.
- `Replace(Input: Text; Pattern: Text; Replacement: Text; Count: Integer; StartAt: Integer; var RegexOptions: Record "Regex Options"): Text`: In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.
- `Replace(Input: Text; Pattern: Text; Replacement: Text): Text`: Replaces all strings that match a specified regular expression with a specified replacement string.
- `Replace(Input: Text; Replacement: Text): Text`: Replaces all strings that match a specified regular expression specified in the Regex constructor with a specified replacement string.
- `Replace(Input: Text; Pattern: Text; Replacement: Text; var RegexOptions: Record "Regex Options"): Text`: Replaces all strings that match a specified regular expression with a specified replacement string. Specified options modify the matching operation.
- `Split(Input: Text; Pattern: Text; Count: Integer; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern.
- `Split(Input: Text; Count: Integer; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern specified in the Regex constructor.
- `Split(Input: Text; Pattern: Text; Count: Integer; var RegexOptions: Record "Regex Options"; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern.
- `Split(Input: Text; Pattern: Text; Count: Integer; StartAt: Integer; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern. The search for the pattern starts at a specified character position in the input string.
- `Split(Input: Text; Count: Integer; StartAt: Integer; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern specified in the Regex constructor. The search for the pattern starts at a specified character position in the input string.
- `Split(Input: Text; Pattern: Text; Count: Integer; StartAt: Integer; var RegexOptions: Record "Regex Options"; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern. The search for the pattern starts at a specified character position in the input string.
- `Split(Input: Text; Pattern: Text; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern. Specified options modify the matching operation.
- `Split(Input: Text; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern specified in the Regex constructor. Specified options modify the matching operation.
- `Split(Input: Text; Pattern: Text; var RegexOptions: Record "Regex Options"; var Array: List of [Text])`: Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern. Specified options modify the matching operation.
- `GetHashCode(): Integer`: Serves as the default hash function.
- `Escape(String: Text): Text`: Escapes a minimal set of characters (\, *, +, ?, \|, {, [, (,), ^, $, ., #, and white space) by replacing them with their escape codes.
- `Unescape(String: Text): Text`: Converts any escaped characters in the input string.
- `Groups(var MatchesRec: Record Matches; var GroupsRec: Record Groups)`: Get the Groups for one particular Match.
- `Captures(var GroupsRec: Record Groups; var CapturesRec: Record Captures)`: Get the Captures for one particular Group.
- `MatchResult(var Matches: Record Matches; Replacement: Text): Text`: Returns the expansion of the specified replacement pattern.

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 3961 "Regex Impl."](../codeunit/3961.md) (17 calls: `Captures → Captures`, `Escape → Escape`, `GetCacheSize → GetCacheSize`, …)

## Called by

- [Codeunit 20416 "Qlty. Expression Mgmt."](../codeunit/20416.md) (4 calls: `EvaluateBuiltInTableLookups → Groups`, `EvaluateBuiltInTableLookups → Match`, `EvaluateFirstStringOnlyFunctions → Groups`, …)
- [Codeunit 2012 "Entity Text Impl."](../codeunit/2012.md) (2 calls: `IsGoodCompletion → Match`, `SetText → Replace`)
- [Codeunit 20403 "Qlty. Filter Helpers"](../codeunit/20403.md) (2 calls: `DeserializeFilterIntoItemAttributesBuffer → Groups`, `DeserializeFilterIntoItemAttributesBuffer → Match`)
- [Codeunit 5069 "Word Template Interactions"](../codeunit/5069.md) (2 calls: `GetAllValuesFromHtmlTable → Groups`, `GetAllValuesFromHtmlTable → Match`)
- [Codeunit 10 "Type Helper"](../codeunit/10.md) (1 call: `IsPhoneNumber → IsMatch`)
- [Codeunit 102 "Import Consolidation from API"](../codeunit/102.md) (1 call: `GetAADTenantIdFromBCUrl → Match`)
- [Codeunit 1034 "Job Planning Line - Calendar"](../codeunit/1034.md) (1 call: `GetHtmlDescription → Replace`)
- [Codeunit 1203 "Import XML File to Data Exch."](../codeunit/1203.md) (1 call: `EscapeMissingNamespacePrefix → IsMatch`)
- [Codeunit 1249 "Transform. Rule - Replace"](../codeunit/1249.md) (1 call: `RegularExpressionReplace → Replace`)
- [Codeunit 1294 "OCR Service Mgt."](../codeunit/1294.md) (1 call: `GetDocuments → IsMatch`)
- [Codeunit 1890 "Reminder Communication"](../codeunit/1890.md) (1 call: `StripHtmlTags → Replace`)
- [Codeunit 20353 "Connectivity Apps Logo Mgt."](../codeunit/20353.md) (1 call: `GetAppURLParametersFromAppSourceURL → Match`)
- [Codeunit 3060 "Uri"](../codeunit/3060.md) (1 call: `IsValidURIPattern → IsMatch`)
- [Codeunit 4513 "SMTP Connector Impl."](../codeunit/4513.md) (1 call: `GetSmtpErrorCodeFromResponse → IsMatch`)
- [Codeunit 47 "StringConversionManagement"](../codeunit/47.md) (1 call: `RemoveNonAlphaNumericCharacters → Replace`)
- [Codeunit 4751 "Recommended Apps Impl."](../codeunit/4751.md) (1 call: `GetAppURLParametersFromAppSourceURL → Match`)
- [Codeunit 560 "CrossIntercompany Connector"](../codeunit/560.md) (1 call: `IsValidTenantIdentifier → IsMatch`)
- [Codeunit 8351 "MCP Config Implementation"](../codeunit/8351.md) (1 call: `EncodeForMCPHeaderIfNonAscii → IsMatch`)
- [Codeunit 9204 "IDA 1D Code39 Encoder"](../codeunit/9204.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9205 "IDA 1D Code93 Encoder"](../codeunit/9205.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9206 "IDA 1D Code128 Encoder"](../codeunit/9206.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9207 "IDA 1D EAN8 Encoder"](../codeunit/9207.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9208 "IDA 1D EAN13 Encoder"](../codeunit/9208.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9209 "IDA 1D I2of5 Encoder"](../codeunit/9209.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9210 "IDA 1D MSI Encoder"](../codeunit/9210.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9211 "IDA 1D Postnet Encoder"](../codeunit/9211.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9212 "IDA 1D UPCA Encoder"](../codeunit/9212.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9213 "IDA 1D UPCE Encoder"](../codeunit/9213.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9214 "IDA 1D Codabar Encoder"](../codeunit/9214.md) (1 call: `IsValidInput → IsMatch`)
- [Codeunit 9988 "Word Template Impl."](../codeunit/9988.md) (1 call: `GetTemplateName → Replace`)
- [Table 2020 "Image Analysis Setup"](../table/2020.md) (1 call: `EndsInAnalyze → IsMatch`)
- [Table 5392 "CRM Annotation Coupling"](../table/5392.md) (1 call: `ExtractNoteText → Replace`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: none

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Regex")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
