SearchPatternAndReplace Function

Syntax

String SearchPatternAndReplace(String string, String searchPattern, String replacementString, [Number startIndex = 0], [Boolean ignoreCase = False], [Number maxReplacements = -1], [Out] [Number numReplacements])

Return Value

String

The modified string.

Purpose

This function searches and replaces one or more substrings that match a regular expression pattern.

Parameters

string as String

The string in which to perform substring replacements.

searchPattern as String

The regular expression pattern to find and then replace with the replacement string.

Note The regular expression pattern follows the standard ECMAScript grammar. Refer to the Microsoft documentation for regular expressions for more information.

replacementString as String

The replacement string.

startIndex as Number

(Optional) A number that specifies the zero-based character index at which to begin searching. The default is 0.

ignoreCase as Boolean

(Optional) A Boolean that specifies whether to ignore character case when searching. The default is False.

maxReplacements as Number

(Optional) A number that specifies the maximum number of occurrences of the substring to replace. A value of -1 signals the function to replace all occurrences of the substring. The default is -1.

numReplacements as Number

(Optional) The number of replacements.