- 4 minutes to read

RegEx search field expression type plugin

Use this plugin to extract values from small messages using a Regular Expression (RegEx).

The Nodinite RegEx Search Field Expression Type plugin can be used to match/style one or more unique values from the payload (Body) of Log Events (business transactions).

Flat files
X12/EDI (Edifact)
Flat files
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
<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>
CityId="([0-9]+)"
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


How to use

To extract values from XML messages you must first configure the Search Field, in this example case; The City part:

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

  1. Enter an appropriate payload in the 'Message Body' tab
  2. Select the 'RegEx' expression type plugin
    Select Search Field Expression Plugin
    Here's an example selecting the 'RegEx' Search Field Expression Plugin.
  3. Enter valid RegEx expression (You can also click on elements/attributes to get a suggestion)
  4. 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.
Test Expression
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:
No Result
Here's an example with an invalid expression, which yields no result.

Examples

graph LR subgraph "Search Fields" sf(fal:fa-search-plus Order Number) end subgraph "Search Field Expressions" sfe(fal:fa-flask RegEx plugin) end subgraph "MessageTypes" mt1(fal:fa-file Orders) end sf --- sfe sfe ---|Expression| mt1

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

Type Expression Value(s) Match Comment
Alternative dog|cat the cat loves the dog cat and dog Use a | character to match at least one alternative
Concatenation h how h A sequence of sub expressions and matches results with the expression only
Grouping a(ero|ir)plane airplane and aeroplane are both English terms airplane and aeroplane Use parentheses for a grouping match
Iteration go*gle gogle, google or gooooogle ggle, gogle, google, gooogle Use a wildcard * character to match infinite combinations
Length ... longword lon and gwo Use a dot, . to match any character. Repeat the number of dots to extract the matching number of characters from the string.
NOTE: Using a dot is risky as it matches just about anything except line breaks, you should try other options
Matching [lsh]and land sand hand land sand hand Use brackets to match on the specified characters

Next Step

How to Add or manage Search Fields
How to Add or manage Log Views

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?