Example
In this example, we will pass the required parameters to the function transformation object using a Variables object.
Where,
Regular Expression (Pattern) = ^H[\S]{0,4}|$
String = 1234HelloWorld!
startAt = 4
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”, as the startAt position is “4”.
In the output window, you can see that Astera has returned a string value, as the regular expression pattern has been matched in accordance with the defined starting position.
Name
GetMatchRegEx
Syntax
GetMatchRegEx (String pattern, String str, Integer startAt)
Purpose
To return a result if a match was found. Otherwise, returns an empty string.
Description
Scans the string, starting at the specified (interger) position, 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
startAt [System.Int64] – The character position at which to start the search