RegEx search field expression type plugin
Use this plugin to extract values from small messages
The Nodinite RegEx Search Field Expression Type plugin can be used to match/style one or more unique values from payload in your logged documents.
- Flat files
- EDI/X12
- XML
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 | Expression | Result |
---|---|---|
|
|
CityId="054" CityId="08" |
XML Data | RegEx expression | Unique values |
Features
- Extract single or multiple unique values from messages (payload)
- Use any RegEx expression to match and/or style data
This plugin loads the entire message into RAM, so make sure to apply this extraction method on smaller messages only
Other RegEx related plugins
- RegEx with capturing groups
- RegEx on Message Context
- RegEx on Message Context with capturing groups
- XPath with RegEx
How to use
To extract values from XML messages you must first configure the Search Field, in this example case; The City part:
- Select expression type plugin
- Enter an 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' expression type plugin
- Enter valid RegEx expression (You can also click on elements/attributes to get a suggestion)
- Review result/output, rewrite the code in step 3 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:
Invalid expression yields no result
Examples
Basic example #1: XML
To extract all Ids for cities with for the Message Type 'Common.Schemas/Nodinite/1.0#Orders
' you can use the following valid expression 'CityId="([0-9]+)"
'. This expression yields the unique values CityId="054"
and CityId="08"
Message Body
<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0">
<Order>
<Id>101</Id>
<Amount>1337</Amount>
<City CityId="054">Karlstad</City>
</Order>
<Order>
<Id>102</Id>
<Amount>10</Amount>
<City CityId="08">Stockholm</City>
</Order>
</ns0:Orders>
Expression
CityId="([0-9]+)"
Additional examples
Concatenation, which describes a sequence of sub expressions and matches results with the expression only.
Example: if "h" is the Expression and "how" is the Message Type Data, the result is that "h" is a match.
Alternatives, which is described by a vertical line, |, is used to match at least one alternative.
Example: "dog|cat" matches both "dog" and "cat".
Iteration, which is described by an asterisk, *, is used to match an expression which is repeated 0 or more times.
Example: "go*gle" has an infinite number of matches which includes: "ggle", "gogle", "google", "gooogle" and so on.
Grouping of expressions, which is done with parentheses.
Example: a(ero|ir)plane will match both aeroplane and airplane.
Matching is described by brackets and uses one of some characters followed by certain characters.
Example: [lsh][]and matches land, sand, and hand.
A dot, .
, can be used as all characters.
Example: writing ten dots will give you all unique results with ten different characters in every paragraph.
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?