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
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.
|XML Data||RegEx expression||Unique values|
- 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 make sure to apply this extraction method on smaller messages only
- RegEx with capturing groups
- RegEx on Message Context
- RegEx on Message Context with capturing groups
- XPath with RegEx
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.
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
Values will be automatically 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
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
<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>
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 will be 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.