Core Triggers and Actions - Regular Expression Action

The documents in this section discuss the core triggers and actions in Flux.

Results

The Regular Expression Action returns its results in the flow context variable “result”. These results include the groups matched by the regular expression pattern, the total number of matches, and an indication of whether the input string contained the regular expression pattern at all:

Flow Context Variable Field Java Type Description Prescript / Postscript Example
RESULT matched boolean Indicates whether the regular expression pattern was found in the input content. boolean matched = flowContext.get("RESULT").matched; System.out.println("Matched? " + matched);
RESULT end int The 0-based index of the last character matched in the input. int end = flowContext.get("RESULT").end; System.out.println("Index of last character matched: " + end);
RESULT groupCount int The number of matches found. int groupCount = flowContext.get("RESULT").groupCount; System.out.println("Total Matches: " + groupCount);
RESULT groups String[] The input sequences matched by the regular expression pattern.
If the replaceFirst and/or replaceAll properties are used, this result will contain the replaced text.
groups[0] contains the matching pattern, groups[1] contains the first regular expression group matched, groups[2] the second matching group, etc.
String[] groups = flowContext.get("RESULT").groups; for (String group : groups) { System.out.println(group); }
RESULT start int The 0-based location of the first occurrence of the regular expression matched in the input file or input string. int start = flowContext.get("RESULT").start; System.out.println("Index of first character matched: " + start);

Passing Results with a Runtime Data Map

You can use a Runtime Data Map to copy one of the result fields into a new variable (for future reference or to reuse the data later in the workflow).

You could pass the list of matching groups into a For Each Collection Element Action using the following map:

Instruction 1 of 2

You can also save the results into a new variable:

Instruction 2 of 2