PREP_PROCESS_REGEX

Use the PREP_PROCESS_REGEX script function to find occurrences of a pattern in a string or process handle. You can use this script element with regular expressions and process handles, and you can also select specific columns and work only within them. With process handles, the function counts occurrences across all lines. To find multiple occurrences within a single line, activate the 'g' flag.

Note: The terms Data Sequences and Text Containers are used interchangeably.

Syntax

When used with a string:

PREP_PROCESS_REGEX (String, Regex [, Group[, Column[, Flags]]])

When used with a process handle:

PREP_PROCESS_REGEX (Handle, Regex [, Group[, Column[, Flags]]])

Parameters

Parameter Description Format Allowed Values Default Value
String or Handle Unicode character string or handle to search Script literal or script variable n.a. n.a.
Regex Regular expression to use. The regular expression uses the Boost C++ Libraries syntax. For more information, see the official Boost C++ Libraries documentation. Script literal or script variable n.a. n.a.
Group

(Optional)

Selection group. The number of the sub-expression (group) used in the regular expression starts with index 1; the number 0 selects the text that matches the whole regular expression. Script literal or script variable n.a. 0
Column

(Optional)

The index indicates which column to search, beginning with 1, or the entire line if the index is 0. If the loaded text container (data sequence) had columns defined, you can select a specific column and work within it; to do so, you must know which column delimiter was used when the text container was loaded. Otherwise, you can define the delimiter using the 'd' flag. Script literal, script variable, or number without quotation marks n.a. 0
Flags

(Optional)

Use flags to modify the operation. Flags can be combined and provided in any order — for example, combine i with n as "in" or "ni", or use the script variable &FLAG#. Script literal or script variable
  • i — Case-insensitive. By default, the search is case sensitive.

  • g — Globally (applies to all occurrences in a line instead of only one or the first). When provided, the function finds all matches in a line; otherwise it finds only the first match in a line.

  • n — Not match null (for example, with "\d*"). The "*" qualifier searches for zero or more occurrences and tries to find as many as possible, which can return zero occurrences; this flag avoids that behavior.

  • d — Delimiter that separates columns. Lets you define a specific delimiter (any text of at least one character) to virtually break text into columns. The delimiter is enclosed by the character immediately following the "d", overriding any default delimiter the text container might have. For example: d' ' for a single blank space, d'$$' for two dollar signs, d+,+ for a comma, or d!foo! for the word "foo".

n.a.

Examples

Example 1 - Checking the report of a File Transfer for failed transfers in Post Processing:

!* Get file names from the report of files that could not be transferred

:SET &HND# = PREP_PROCESS_REPORT(,,REP)

:GREP_PROCESS &HND#"U00063018"

:SET &REGEX# = "file '([^']+)'"

:SET &HND_FILES# = PREP_PROCESS_REGEX(&HND#&REGEX#, 1)

:PROCESS &HND_FILES#

:   SET &FILE# = GET_PROCESS_LINE(&HND_FILES#)

:   PRINT "Failed to transfer file: &FILE#"

:ENDPROCESS

After executing the File Transfer, the post processing report (POST) displays the following:

2025-08-06 11:33:32 - U00020408 Failed to transfer file: /tmp/src/db3.txt
2025-08-06 11:33:32 - U00020408 Failed to transfer file: /tmp/src/db2.txt

The job report (REP) provides further information:

2025-08-06 11:33:32 - U00063097 FT '74021700': Initiating connection to Agent 'AR_MAIN_JLX6_VWGARLNX02_02'.
2025-08-06 11:33:32 - U00063013 FT '74021700': Connecting to 'xx.xxx.xxx.xxx' at port '2242'.
2025-08-06 11:33:32 - U00063092 FT '74021700': Connection to Agent 'AR_MAIN_JLX6_VWGARLNX02_02 (socket handle = '2')' was successfully established.
2025-08-06 11:33:32 - U00063087 FT '74021700': Selection started with filter '/tmp/src/*.txt' ...
2025-08-06 11:33:32 - U00063088 FT '74021700': '/tmp/src/db3.txt'
2025-08-06 11:33:32 - U00063088 FT '74021700': '/tmp/src/db1.txt'
2025-08-06 11:33:32 - U00063088 FT '74021700': '/tmp/src/db2.txt'
2025-08-06 11:33:32 - U00063089 FT '74021700': Files selected: '3'.
2025-08-06 11:33:32 - U00063091 FT '74021700': Directories selected: '0'.
2025-08-06 11:33:32 - U00063018 FT '74021700': Cannot open file '/tmp/src/db3.txt'. Error: 'Access is denied'.
2025-08-06 11:33:32 - U00063018 FT '74021700': Cannot open file '/tmp/src/db2.txt'. Error: 'Access is denied'.
2025-08-06 11:33:32 - U00011133 OK '5313' Bytes, '159' Records for file '/tmp/src/db1.txt'->'/tmp/dst/db1.txt' transferred. Duration '00:00:00'.
2025-08-06 11:33:32 - U00011409 FT '74021700': File Transfer has ended abnormally.

Example 2 - Checking the report of a File Transfer for the failed transfer file names in Post Processing, also using a column delimiter and picking a specific column:

!* Get file names from the report of files that could not be transferred using a column delimiter ' and picking column 4 and selecting there everything with ".*"

:SET &HND# = PREP_PROCESS_REPORT(,,REP)

:GREP_PROCESS &HND#"U00063018"

:SET &HND_FILES# = PREP_PROCESS_REGEX(&HND#".*",, 4, "d/'/")

:PROCESS &HND_FILES#

:   SET &FILE# = GET_PROCESS_LINE(&HND_FILES#)

:   PRINT "Failed to transfer file: &FILE#"

:ENDPROCESS

After executing the File Transfer, the post processing report (POST) displays the following:

2025-08-06 11:41:58 - U00020408 Failed to transfer file: /tmp/src/db3.txt
2025-08-06 11:41:58 - U00020408 Failed to transfer file: /tmp/src/db2.txt

The job report (REP) provides further information:

2025-08-06 11:41:58 - U00063097 FT '74035267': Initiating connection to Agent 'AR_MAIN_JLX6_VWGARLNX02_02'.
2025-08-06 11:41:58 - U00063013 FT '74035267': Connecting to 'xx.xxx.xxx.xxx' at port '2242'.
2025-08-06 11:41:58 - U00063092 FT '74035267': Connection to Agent 'AR_MAIN_JLX6_VWGARLNX02_02 (socket handle = '3')' was successfully established.
2025-08-06 11:41:58 - U00063087 FT '74035267': Selection started with filter '/tmp/src/*.txt' ...
2025-08-06 11:41:58 - U00063088 FT '74035267': '/tmp/src/db3.txt'
2025-08-06 11:41:58 - U00063088 FT '74035267': '/tmp/src/db1.txt'
2025-08-06 11:41:58 - U00063088 FT '74035267': '/tmp/src/db2.txt'
2025-08-06 11:41:58 - U00063089 FT '74035267': Files selected: '3'.
2025-08-06 11:41:58 - U00063091 FT '74035267': Directories selected: '0'.
2025-08-06 11:41:58 - U00063018 FT '74035267': Cannot open file '/tmp/src/db3.txt'. Error: 'Access is denied'.
2025-08-06 11:41:58 - U00063018 FT '74035267': Cannot open file '/tmp/src/db2.txt'. Error: 'Access is denied'.
2025-08-06 11:41:58 - U00011133 OK '5313' Bytes, '159' Records for file '/tmp/src/db1.txt'->'/tmp/dst/db1.txt' transferred. Duration '00:00:00'.
2025-08-06 11:41:58 - U00011409 FT '74035267': File Transfer has ended abnormally.

Example 3 - Loading a text container with the content of a Vara object, also working with and within columns and with flags:

!* Load text container with content of VARA object

:SET &HND_VARA# = PREP_PROCESS_VAR(RT.999.VARA.CONTENTFILE)

!* Get all keys of the VARA (which are in column 1)

:SET &REGEX# = ".+"

:SET &HND_KEYS# = PREP_PROCESS_REGEX(&HND_VARA#&REGEX#,, 1)

:SET &NUMBER_KEYS# = GET_PROCESS_INFO(&HND_KEYS#ROWS)

!* Output

:PROCESS &HND_KEYS#

:   SET &KEY# = GET_PROCESS_LINE(&HND_KEYS#)

:   PRINT &KEY#

:ENDPROCESS

:PRINT number of keys in all columns: &NUMBER_KEYS#

:CLOSE_PROCESS &HND_KEYS#

!--

!* Count and get all words of the text in VARA which is in column 2

:SET &REGEX# = "\w+"

:SET &NUMBER_WORDS# = REGEX_COUNT(&HND_VARA#&REGEX#, 2, "g")

:SET &HND_WORDS# = PREP_PROCESS_REGEX(&HND_VARA#&REGEX#,, 2, "g")

:SET &NUMBER_LINES# = GET_PROCESS_INFO(&HND_WORDS#ROWS)

!* Output

:PROCESS &HND_WORDS#

:   SET &WORD# = GET_PROCESS_LINE(&HND_WORDS#)

:   PRINT &WORD#

:ENDPROCESS

:PRINT number of words in column 2: &NUMBER_WORDS#

:PRINT number of lines: &NUMBER_LINES#

:CLOSE_PROCESS &HND_KEYS#

!--

!* Get and count words in VARA column 2 but get only first character

:SET &REGEX# = "(\w)\w*"

:SET &HND_CHAR# = PREP_PROCESS_REGEX(&HND_VARA#&REGEX#, 1, 2, "g")

:SET &NUMBER_CHARS# = GET_PROCESS_INFO(&HND_CHAR#ROWS)

!* Output

:PROCESS &HND_CHAR#

:   SET &CHAR# = GET_PROCESS_LINE(&HND_CHAR#)

:   PRINT &CHAR#

:ENDPROCESS

:PRINT number of first letters of words in column 2: &NUMBER_CHARS#

:CLOSE_PROCESS &HND_CHAR#

See also: