Table of Contents

Codeunit Regex

ID 3960
Namespace: System.Utilities

Provides functionality to use regular expressions to match text, split text, replace text etc.

Properties

Name Value
Access Public
InherentEntitlements X
InherentPermissions X

Methods

Regex

Initializes a new instance of the Regex class for the specified regular expression.

procedure Regex(Pattern: Text)

Parameters

Name Type Description
Pattern Text

A regular expression pattern to match.

Regex

Initializes a new instance of the Regex class for the specified regular expression, with options that modify the pattern.

procedure Regex(Pattern: Text, var RegexOptions: Record "Regex Options" temporary)

Parameters

Name Type Description
Pattern Text

A regular expression pattern to match.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that modify the regular expression.

GetCacheSize

Gets the maximum number of entries in the current static cache of compiled regular expressions.

procedure GetCacheSize(): Integer

Returns

Type Description
Integer

The maximum number of entries in the static cache.

SetCacheSize

Sets the maximum number of entries in the current static cache of compiled regular expressions.

procedure SetCacheSize(CacheSize: Integer)

Parameters

Name Type Description
CacheSize Integer

The maximum number of entries in the static cache.

GetGroupNames

Gets an array of capturing group names for the regular expression.

procedure GetGroupNames(var GroupNames: List of [Text])

Parameters

Name Type Description
GroupNames List of [Text]

An list of group names.

GetGroupNumbers

Gets an array of capturing group numbers that correspond to group names in an array.

procedure GetGroupNumbers(var GroupNumbers: List of [Integer])

Parameters

Name Type Description
GroupNumbers List of [Integer]

An array of group numbers.

GroupNameFromNumber

Gets the group name that corresponds to the specified group number.

procedure GroupNameFromNumber(Number: Integer): Text

Parameters

Name Type Description
Number Integer

The group number to convert to the corresponding group name.

Returns

Type Description
Text

A string that contains the group name associated with the specified group number. If there is no group name that corresponds to i, the method returns Empty.

GroupNumberFromName

Gets the group number that corresponds to the specified group name.

procedure GroupNumberFromName(Name: Text): Integer

Parameters

Name Type Description
Name Text

The group name to convert to the corresponding group number.

Returns

Type Description
Integer

The group number that corresponds to the specified group name, or -1 if name is not a valid group name.

IsMatch

Indicates whether the regular expression finds a match in the input string, beginning at the specified starting position in the string.

procedure IsMatch(Input: Text, Pattern: Text, StartAt: Integer): Boolean

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

StartAt Integer

The character position at which to start the search.

Returns

Type Description
Boolean

True if the regular expression finds a match; otherwise, false.

IsMatch

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.

procedure IsMatch(Input: Text, StartAt: Integer): Boolean

Parameters

Name Type Description
Input Text

The string to search for a match.

StartAt Integer

The character position at which to start the search.

Returns

Type Description
Boolean

True if the regular expression finds a match; otherwise, false.

IsMatch

Indicates whether the regular expression finds a match in the input string, beginning at the specified starting position in the string.

procedure IsMatch(Input: Text, Pattern: Text, StartAt: Integer, var RegexOptions: Record "Regex Options" temporary): Boolean

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

StartAt Integer

The character position at which to start the search.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that modify the regular expression.

Returns

Type Description
Boolean

True if the regular expression finds a match; otherwise, false.

IsMatch

Indicates whether the regular expression finds a match in the input string.

procedure IsMatch(Input: Text, Pattern: Text): Boolean

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Returns

Type Description
Boolean

True if the regular expression finds a match; otherwise, false.

IsMatch

Indicates whether the regular expression specified in the Regex constructor finds a match in the input string.

procedure IsMatch(Input: Text): Boolean

Parameters

Name Type Description
Input Text

The string to search for a match.

Returns

Type Description
Boolean

True if the regular expression finds a match; otherwise, false.

IsMatch

Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options.

procedure IsMatch(Input: Text, Pattern: Text, var RegexOptions: Record "Regex Options" temporary): Boolean

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that modify the regular expression.

Returns

Type Description
Boolean

True if the regular expression finds a match; otherwise, false.

Match

Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.

procedure Match(Input: Text, Pattern: Text, StartAt: Integer, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

StartAt Integer

The zero-based character position at which to start the search.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

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.

procedure Match(Input: Text, StartAt: Integer, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

StartAt Integer

The zero-based character position at which to start the search.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.

procedure Match(Input: Text, Pattern: Text, StartAt: Integer, var RegexOptions: Record "Regex Options" temporary, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

StartAt Integer

The zero-based character position at which to start the search.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

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.

procedure Match(Input: Text, Pattern: Text, StartAt: Integer, Length: Integer, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

StartAt Integer

The zero-based character position in the input string that defines the leftmost position to be searched.

Length Integer

The number of characters in the substring to include in the search.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

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.

procedure Match(Input: Text, StartAt: Integer, Length: Integer, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

StartAt Integer

The zero-based character position in the input string that defines the leftmost position to be searched.

Length Integer

The number of characters in the substring to include in the search.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

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.

procedure Match(Input: Text, Pattern: Text, StartAt: Integer, Length: Integer, var RegexOptions: Record "Regex Options" temporary, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

StartAt Integer

The zero-based character position in the input string that defines the leftmost position to be searched.

Length Integer

The number of characters in the substring to include in the search.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

Searches the input string for the first occurrence of the specified regular expression, using the specified matching options.

procedure Match(Input: Text, Pattern: Text, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

Searches the input string for the first occurrence of the specified regular expression specified in the Regex constructor, using the specified matching options.

procedure Match(Input: Text, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Match

Searches the input string for the first occurrence of the specified regular expression, using the specified matching options.

procedure Match(Input: Text, Pattern: Text, var RegexOptions: Record "Regex Options" temporary, var Matches: Record Matches temporary)

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Matches Table System.Utilities.Matches

The Match object to write information about the match to.

Replace

Replaces strings that match a regular expression pattern with a specified replacement string.

procedure Replace(Input: Text, Pattern: Text, Replacement: Text, Count: Integer): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Replacement Text

The replacement string.

Count Integer

The maximum number of times the replacement can occur.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

Replaces strings that match a regular expression pattern specified in the Regex constructor with a specified replacement string.

procedure Replace(Input: Text, Replacement: Text, Count: Integer): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Replacement Text

The replacement string.

Count Integer

The maximum number of times the replacement can occur.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

Replaces strings that match a regular expression pattern with a specified replacement string.

procedure Replace(Input: Text, Pattern: Text, Replacement: Text, Count: Integer, var RegexOptions: Record "Regex Options" temporary): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Replacement Text

The replacement string.

Count Integer

The maximum number of times the replacement can occur.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.

procedure Replace(Input: Text, Pattern: Text, Replacement: Text, Count: Integer, StartAt: Integer): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Replacement Text

The replacement string.

Count Integer

The maximum number of times the replacement can occur.

StartAt Integer

The character position in the input string where the search begins.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

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.

procedure Replace(Input: Text, Replacement: Text, Count: Integer, StartAt: Integer): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Replacement Text

The replacement string.

Count Integer

The maximum number of times the replacement can occur.

StartAt Integer

The character position in the input string where the search begins.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.

procedure Replace(Input: Text, Pattern: Text, Replacement: Text, Count: Integer, StartAt: Integer, var RegexOptions: Record "Regex Options" temporary): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Replacement Text

The replacement string.

Count Integer

The maximum number of times the replacement can occur.

StartAt Integer

The character position in the input string where the search begins.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

Replaces all strings that match a specified regular expression with a specified replacement string.

procedure Replace(Input: Text, Pattern: Text, Replacement: Text): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Replacement Text

The replacement string.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

Replaces all strings that match a specified regular expression specified in the Regex constructor with a specified replacement string.

procedure Replace(Input: Text, Replacement: Text): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Replacement Text

The replacement string.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Replace

Replaces all strings that match a specified regular expression with a specified replacement string. Specified options modify the matching operation.

procedure Replace(Input: Text, Pattern: Text, Replacement: Text, var RegexOptions: Record "Regex Options" temporary): Text

Parameters

Name Type Description
Input Text

The string to search for a match.

Pattern Text

A regular expression pattern to match.

Replacement Text

The replacement string.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Returns

Type Description
Text

A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the pattern is not matched the method returns the current instance unchanged

Split

Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern.

procedure Split(Input: Text, Pattern: Text, Count: Integer, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Pattern Text

A regular expression pattern to match.

Count Integer

The maximum number of times the split can occur.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

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.

procedure Split(Input: Text, Count: Integer, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Count Integer

The maximum number of times the split can occur.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern.

procedure Split(Input: Text, Pattern: Text, Count: Integer, var RegexOptions: Record "Regex Options" temporary, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Pattern Text

A regular expression pattern to match.

Count Integer

The maximum number of times the split can occur.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

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.

procedure Split(Input: Text, Pattern: Text, Count: Integer, StartAt: Integer, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Pattern Text

A regular expression pattern to match.

Count Integer

The maximum number of times the split can occur.

StartAt Integer

The character position in the input string where the search will begin.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

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.

procedure Split(Input: Text, Count: Integer, StartAt: Integer, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Count Integer

The maximum number of times the split can occur.

StartAt Integer

The character position in the input string where the search will begin.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

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.

procedure Split(Input: Text, Pattern: Text, Count: Integer, StartAt: Integer, var RegexOptions: Record "Regex Options" temporary, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Pattern Text

A regular expression pattern to match.

Count Integer

The maximum number of times the split can occur.

StartAt Integer

The character position in the input string where the search will begin.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

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.

procedure Split(Input: Text, Pattern: Text, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Pattern Text

A regular expression pattern to match.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

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.

procedure Split(Input: Text, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Array List of [Text]

An empty list that will be populated with the result of the split query.

Split

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.

procedure Split(Input: Text, Pattern: Text, var RegexOptions: Record "Regex Options" temporary, var Array: List of [Text])

Parameters

Name Type Description
Input Text

The string to split.

Pattern Text

A regular expression pattern to match.

RegexOptions Table System.Utilities."Regex Options"

A combination of the enumeration values that provide options for matching.

Array List of [Text]

An empty list that will be populated with the result of the split query.

GetHashCode

Serves as the default hash function.

procedure GetHashCode(): Integer

Returns

Type Description
Integer

A hash code for the current object.

Escape

Escapes a minimal set of characters (, *, +, ?, |, {, [, (,), ^, $, ., #, and white space) by replacing them with their escape codes.

procedure Escape(String: Text): Text

Parameters

Name Type Description
String Text

The input string that contains the text to convert.

Returns

Type Description
Text

A string of characters with metacharacters converted to their escaped form.

Unescape

Converts any escaped characters in the input string.

procedure Unescape(String: Text): Text

Parameters

Name Type Description
String Text

The input string containing the text to convert.

Returns

Type Description
Text

A string of characters with any escaped characters converted to their unescaped form.

Groups

Get the Groups for one particular Match.

procedure Groups(var MatchesRec: Record Matches temporary, var GroupsRec: Record Groups temporary)

Parameters

Name Type Description
MatchesRec Table System.Utilities.Matches

The Match record to get Groups for.

GroupsRec Table System.Utilities.Groups

Groups Record to write the resulting Groups to.

Captures

Get the Captures for one particular Group.

procedure Captures(var GroupsRec: Record Groups temporary, var CapturesRec: Record Captures temporary)

Parameters

Name Type Description
GroupsRec Table System.Utilities.Groups

The Group record to get Captures for.

CapturesRec Table System.Utilities.Captures

Captures Record to write the resulting Captures to.

MatchResult

Returns the expansion of the specified replacement pattern.

procedure MatchResult(var Matches: Record Matches temporary, Replacement: Text): Text

Parameters

Name Type Description
Matches Table System.Utilities.Matches

The Match Record to perform replacement on.

Replacement Text

The replacement pattern to use.

Returns

Type Description
Text

The expanded version of the replacement parameter.

See also