RegEx on Message Context search field expression type plugin
Use this plugin to extract values from XML content from the collection of Context Properties.
Use the Nodinite RegEx on Message Context Search Field Expression Type to extract values for a Search Field. Us this feature to extract One or more unique values from the collection of Context Properties.
A Logged message comes from a Log Event that is part of the Logging feature of Nodinite, and the Search Fields are further used within self-service enabled Log Views for your business.
Quick example
Let's get you started with the following simple demonstration example valid for this search field plugin. For other and more advanced examples, please scroll down on this page to the Examples section.
Input | 1st Expression | 2nd Expression | Result |
---|---|---|---|
|
|
|
456 |
XML Data within Context Property 'XMLContent' | 1st Named Context Property | 2nd XPath expression | Unique values |
Features
- Extract single or multiple unique values from named Context property.
- Use any RegEx expression to match and/or style data.
- Use additional options to refine further the output like the use of capturing groups, Global and Multi line.
Important
This plugin loads the entire message into RAM, so make sure to apply this extraction method on smaller messages only.
Other RegEx related plugins
How to use
To extract values from Context Properties you must first configure the Search Field, in this example case; The File name part:
- Select expression type plugin.
- Enter 1st expression to get the content from named Context property.
- Enter 2nd expression to match/style the content from previous expression.
- Finalize remaining steps including selection of Message Types and optional re-index operation (Add or manage Search Field).
Once a Search Field is configured, values are extracted either during normal processing or from user initiated re-index operations. Extracted values are persisted and stored for as long as the days to keep events property on the Message Type is configured.
Test Expression
You can test an expression when configuring a Search Field in the 'Test Expression' tab.
- Enter an appropriate payload in the 'Message Body' tab.
- Select the 'RegEx on Message Context' expression type plugin.
- Enter 1st Context property expression to get the content.
- Enter 2nd RegEx configuration to match/style the content from returned by step 3.
- RegEx expression - The valid RegEx expression to match data.
- RegEx groups - Enter number or name of RegEx Group(s) to return (leave empty for all matches).
- Global - When checked do not return on first match.
- Multi line - When checked use either
^
for start of line and$
for end of line.
- Review result/output, rewrite the code in step 3-4 until you get the data you seek.
The actual result (values) are extracted by the Logging Service and then presented together with the evaluated processing state and the number of unique matches.
Valid expression with state output, unique values and total count
If the expression is either invalid or does not match any data, then the following output is presented:
Here's an example with an invalid expression, which yields no result.
Examples
Basic example
To extract the 4th field from content in named Context property 'OrderRecord
' and with valid RegEx expression '^(?:(.*?)\|){4}
'. This configuration yields the unique value 456
OrderRecord Context property
ORD|101|ExampleCompany1|456|Company Name ACME |Dieselgate valley 1|123 45|Flameburg|
1st Expression
First enter the named context property.
OrderRecord
2nd Expression
Then configure the RegEx configuration
- RegEx Expression
^(?:(.*?)\|){4}
- RegEx groups = 1
- Global = Unchecked
- Multi line - Unchecked
Next Step
How to Add or manage Search Fields
How to Add or manage Log Views
Related
Expression Type Plugins are used in Search Fields
What are Search Fields?
What are Search Field Expressions?
What are Message Types?
What are Log Views?