Operator RegexRun
This RegexRun operator uses the Boost.Xpressive engine to process regular expressions against incoming input tuples. The operator provides several output functions for detecting partial or full matches and performing replacements.
Example
composite Main {
graph
stream<rstring string> GeneratedStrings = Beacon() {
param
period: 1.0;
output GeneratedStrings: string = "host" + (rstring) IterationCount() + "@teracloud.com";
}
stream<rstring string, boolean isFullMatch, boolean isPartialMatch, rstring replaced> Results = RegexRun(GeneratedStrings) {
param
pattern: "host";
output
Results:
isFullMatch = RegexFullMatch(string),
isPartialMatch = RegexPartialMatch(string),
replaced = RegexGlobalReplace(string, "<redacted>");
}
() as Sink = Custom(Results) {
logic
onTuple Results: {
printStringLn("Original string: " + string);
printStringLn("Full match found? " + (rstring) isFullMatch);
printStringLn("Partial match found? " + (rstring) isPartialMatch);
printStringLn("New string after replacements: " + replaced);
}
}
}
Summary
- Ports
- This operator has 1 input port and 1 output port.
- Windowing
- This operator does not accept any windowing configurations.
- Parameters
- This operator supports 1 parameter.
Optional: pattern
- Metrics
- This operator does not report any metrics.
Properties
- Implementation
- C++
- Threading
- Always - Operator always provides a single threaded execution context.
- Ports (0)
-
The RegexRun operator is configurable with a single input port. The input port is non-mutating and its punctuation mode is Oblivious.
- Properties
-
- Optional: false
- ControlPort: false
- TupleMutationAllowed: false
- WindowingMode: NON_WINDOWED
- WindowPunctuationInputMode: OBLIVIOUS
- Assignments
- This operator allows any SPL expression of the correct type to be assigned to output attributes. Attributes not assigned in the output clause will be automatically assigned from the attributes of the input ports that have the same name and type. If there is no such input attribute, an error is reported at compile-time.
- Output Functions
-
- RegexFS
-
- <any T> T AsIs(T v)
-
Assign value to the output attribute.
- boolean RegexFullMatch(rstring str)
-
Perform full (exact) match of the input string with the value of the pattern parameter. Returns true if match found; false otherwise.
- boolean RegexFullMatch(rstring str, rstring pattern)
-
Perform full (exact) match of the input string with the provided pattern. Returns true if match found; false otherwise.
- boolean RegexPartialMatch(rstring str)
-
Perform partial match of the input string with the value of the pattern parameter. Returns true if match found; false otherwise.
- boolean RegexPartialMatch(rstring str, rstring pattern)
-
Perform partial match of the input string with the provided pattern. Returns true if match found; false otherwise.
- rstring RegexGlobalReplace(rstring str, rstring rewrite)
-
Get an rstring that replaces all matches of the input string (against the value of the pattern parameter) with the value of rewrite.
- rstring RegexGlobalReplace(rstring str, rstring pattern, rstring rewrite)
-
Get an rstring that replaces all matches of the input string (against the provided pattern) with the value of rewrite.
- Ports (0)
-
The RegexRun operator is configurable with one output port. The output port is mutating and its punctuation mode is Preserving.
- Properties
-
- Optional: false
- TupleMutationAllowed: true
- WindowPunctuationOutputMode: PRESERVING
Optional: pattern
- pattern
-
The optional 'rstring' parameter specifies the pattern to match.
- Properties
-
- Type: rstring
- Cardinality: 1
- Optional: true
- ExpressionMode: ATTRIBUTE_FREE
- RegexRun - Boost.Xpressive
-
stream<${schema}> ${outputStream} = com.teracloud.streams.regex.xpressive::RegexRun(${inputStream}) { param pattern: "${pattern}"; output ${outputStream}: ${outputAttribute} = ${value}; }
- No description for library.