---
title: RegEx Search Field Expression Plugin – Extract Whole Matches from the Message Body
description: Use the Nodinite RegEx Search Field Expression plugin to extract every text in the message body that matches a regular expression. The plugin returns the whole match, even when the pattern has capturing groups.
---

# <i class="fal fa-magnifying-glass" aria-hidden="true"></i> RegEx Search Field Expression Plugin

The **RegEx** plugin runs a regular expression on the message body of a [Log Event][] and returns every **whole match** as a [Search Field][Search Fields] value. Use it when the matched text itself is the value you want, in XML, JSON, flat file, or any other text format.

* ✅ Works on any text format in the message body  
* ✅ Returns every match, with duplicates collapsed  
* ✅ Returns the whole match, even when the pattern contains capturing groups  

## <i class="fal fa-scale-balanced" aria-hidden="true"></i> When to use it

Four RegEx plugins cover the combinations of *where the text is* and *what part of the match you want*. For every plugin, see [Choose a plugin][].

| Your data | You want | Use |
| --- | --- | --- |
| Message body | The whole match | **RegEx** (this page) |
| Message body | Only the part inside a capturing group `( )` | [RegEx with capturing groups][] |
| One context value (you know the key) | The whole match | [RegEx on Message Context][] |
| One context value (you know the key) | Only the part inside a capturing group | [RegEx on Message Context with capturing groups][] |
| One context value (you know the key) | The value as it is, no pattern | [Message Context Key][] |
| XML body, pattern on a selected node only | The match within that node | [XPath with RegEx][] |
| A match you need to transform or combine | Nested functions | [Formula][] with [`regex`][Formula regex] or [`regexGroup`][Formula regexGroup] |

## <i class="fal fa-code" aria-hidden="true"></i> Expression syntax

Select **RegEx** in the **Type** list and enter the pattern in the **Expression** field. The plugin has no other settings.

![Type list filtered on regex, with RegEx selected (7.12)][1]  
*The RegEx plugin and its siblings in the Type list.*  

* The plugin returns **every** match in the message body; [Search Fields][] keep unique values only (see [How expressions run][]).
* The result is always the **whole match**. Parentheses in the pattern don't change that: `CityId="([0-9]+)"` returns `CityId="054"`, not `054`. To return only the group, use [RegEx with capturing groups][].
* Matching ignores case: the pattern `cityId` matches `CityId` in Example 1.
* Spaces in the pattern are ignored, and `#` starts a comment: `a b` matches `ab`, not `a b`. Write a literal space as `\s` or `[ ]`, and a literal `#` as `\#`. The info line under **Type** ends with the same rule: *"The pattern ignores case and white space: write a space as `\s` or `[ ]` and # as `\#` (an unescaped # starts a comment)."*
* Each value is trimmed of leading and trailing white space, and an empty match is dropped.
* A pattern may run for 30 seconds per event at most.
* When nothing matches, Test Expression reports *Processed with warning: The Expression yields no result*.

![Expressions tab with Type RegEx and the info line under Type, which ends with the rule for spaces and the hash sign (7.12)][6]  
*The RegEx plugin's fields and info line.*  

![Test Expression result: Processed with warning, The Expression yields no result (7.12)][3]  
*Test result when the pattern matches nothing in the message body.*  

![RegEx with capturing groups on the ORD-10009 order confirmation returns only the mail domain, animated walkthrough (7.12)][4]  
*Animated walkthrough: the sibling plugin [RegEx with capturing groups][] returns only group 1 (`northwind.example.com`); the RegEx plugin would return the whole address `orders@northwind.example.com`.*  

Configure and test the expression as described in [Add or manage Search Field][] and [Test Your Expression][].

## <i class="fal fa-list-ol" aria-hidden="true"></i> Examples

### Example 1: Extract city attributes from an order message

#### Input

```xml
<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

```text
cityId="([0-9]+)"
```

#### Result

```text
CityId="054"
CityId="08"
```

The pattern contains a capturing group, but the RegEx plugin still returns the whole match. To get `054` and `08`, use the same pattern with [RegEx with capturing groups][].

![Test Expression for the RegEx plugin returning two whole CityId matches from an Orders XML message (7.12)][2]  
*Test Expression: two unique whole matches from the Orders message. The first City line is blurred in the screenshot; it is the same as in the input above.*  

### Example 2: Extract invoice numbers from a JSON message

#### Input

```json
{
  "invoices": [
    { "invoiceNo": "INV-2026-0042", "amount": 1250.00 },
    { "invoiceNo": "INV-2026-0043", "amount": 89.50 }
  ]
}
```

#### Expression

```text
INV-\d{4}-\d{4}
```

#### Result

```text
INV-2026-0042
INV-2026-0043
```

The pattern describes the whole value, so the whole match is exactly the invoice number.

![RegEx test: a pattern for INV- followed by two groups of four digits, on a JSON invoice message, returns two invoice numbers (7.12)][5]  
*The pattern matches each `invoiceNo` value in the JSON body.*  

## <i class="fal fa-triangle-exclamation" aria-hidden="true"></i> Limitations

* The plugin reads the whole message body; for large XML or JSON payloads, prefer [XPath][] or [JSON Path][].
* It returns whole matches only. Use [RegEx with capturing groups][] to return part of a match.

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-plus" aria-hidden="true"></i> [Add or manage Search Field][]  
* <i class="fal fa-flask" aria-hidden="true"></i> [Test Your Expression][]  
* <i class="fal fa-signs-post" aria-hidden="true"></i> [Choose a plugin][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [RegEx with capturing groups][]  
* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [RegEx on Message Context][]  
* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [RegEx on Message Context with capturing groups][]  
* <i class="fal fa-key" aria-hidden="true"></i> [Message Context Key][]  
* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [XPath with RegEx][]  
* <i class="fal fa-function" aria-hidden="true"></i> [Formula][]  
* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Search Field Expressions][]  
* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Search Fields][]  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/RegEx/Select.png
[2]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/RegEx/Example1.png
[3]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/NoResult.png
[4]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Expression_RegExGroups.gif
[5]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/RegEx/Example2.png
[6]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/RegEx/Help.png

[Add or manage Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/
[Choose a plugin]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/#fa-signs-post-choose-a-plugin
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[Formula regex]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/regex/
[Formula regexGroup]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/regexgroup/
[How expressions run]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/#fa-gears-how-expressions-run
[JSON Path]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/json-path/
[Log Event]:https://docs.nodinite.com/core-services/log-event/overview/
[Message Context Key]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/message-context-key/
[RegEx on Message Context]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/regex-on-message-context/
[RegEx on Message Context with capturing groups]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/regex-on-message-context-with-capturing-groups/
[RegEx with capturing groups]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/regex-with-capturing-groups/
[Search Field Expressions]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/
[Search Fields]:https://docs.nodinite.com/administration/log-management/search-fields/features/what-is-a-search-field/
[Test Your Expression]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/#test-your-expression
[XPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath/
[XPath with RegEx]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath-with-regex/