GetMatchRegEx
Last updated
Last updated
© Copyright 2023, Astera Software
Name | GetMatchRegEx |
Syntax | GetMatchRegEx (String pattern, String str) |
Purpose | To return a result if a match was found. Otherwise, returns an empty string. |
Description | Scans the string for an occurrence of text matching the specified regular expression. |
Return Type | String |
Parameters | pattern [System.String] – Regular expression pattern to match str [System.String] – String to search for a match |
Example
In this example, we will pass the required parameters to the function transformation object using a Variables object.
Where,
Pattern = ^H[\S]{0,4}|$
String = HelloWorld!
Note: The specified regular expression will look for and match a string which begins with “H” (case sensitive). Next, it will match any character that is not a whitespace character in the next 0 to 4 characters. Finally, the “$” is used to end the string. Therefore, the returned output should be “Hello”.
In the output window, you can see that Astera has returned a string value, as the regular expression pattern has been matched.