Searches for a pattern in a string using a regular expression.
RegExMatch() function has four parameters:
sourceString(string): Required. The string to search using regular expression.
regExPattern(string): Required. The regular expression to use in the search.
returnValue(string): Required. The name or ordinal of the matching group to return.
repeatParameter(string): The repeating string parameter to apply. You can use any value from the .NET RegexOptions enumeration, such as IgnoreCase and Multiline.
To use the function, pass it a string, a regular expression to apply to the string, and the value from the regular expression that you want to return.
This example uses a regular expression to determine if it contains between five and seven alphanumeric characters.
The example outputs a message indicating that the string matched the pattern in the regular expression.
You can combine the
RegExMatch() function with the Replace() function to replace text in a string based on a regex pattern. This example uses the
RegExMatch() function to find between two and five alphanumeric characters at the beginning of a string, followed by one numeric character, followed by a hyphen. It then passes the matching substring to the
Replace() function, which replaces the substring with an empty string.
The function returns the order ID with the characters identified by the regular expression removed.
- RegexOptions Enum in the .NET API documentation.