Formula - replaceregex
Easily replace text using regular expressions in messages with the Nodinite replaceregex
Formula plugin. This page shows how to substitute patterns in message Content, Context, or the output of other formulas.
π― Designed for business users and integrators β no developer required; you can even use AI to craft expressions.
- β Replace patterns from any Payload or Context in any Log Event
- β Use any valid regular expression to match and replace patterns
- β Transform and surface meaningful data in Nodinite Log Views, search filters, and self-service diagnostics
- β Combine with other Formula functions for powerful, layered expressions
What does the replaceregex Formula do?
The replaceregex('Pattern', 'NewValue', Content)
Formula function substitutes all occurrences of a pattern (matched by regular expression) with a new value. Use it on message bodies, context values, or the results from other Formula functions to transform data in your views.
How it works: Input β replaceregex β Result
Flow: The content is processed with a regular expression to replace all matched patterns with the new value.
Example data
<TypedPolling xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedPolling/INT007">
<TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>1401518</ProjectNumber>
<Company>400</Company>
<Activity>1000</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>1401518</ProjectNumber>
<Company>400</Company>
<Activity>1001</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>4831351</ProjectNumber>
<Company>355</Company>
<Activity>1063</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>9233120</ProjectNumber>
<Company>700</Company>
<Activity>3400</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>9402000</ProjectNumber>
<Company>734</Company>
<Activity>5104</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
</TypedPollingResultSet0>
</TypedPolling>
Example of the replaceregex formula function in the Nodinite UI
Example 1 β Replace all numbers with X
Input from body
<ProjectNumber>1401518</ProjectNumber>
Formula Expression
replaceregex('[0-9]', 'X', body)
Result
<ProjectNumber>XXXXXXX</ProjectNumber>
Example: Replacing all digits in the ProjectNumber with 'X' using regex.
Example 2 β Replace DELETE actions with UPDATE
Input
<Action>DELETE</Action>
Formula Expression
replaceregex('DELETE', 'UPDATE', body)
Result
<Action>UPDATE</Action>
Example: Replacing all 'DELETE' actions with 'UPDATE'.
Example 3 β Replace company codes with a placeholder
Input
<Company>400</Company>
Formula Expression
replaceregex('<Company>[0-9]+</Company>', '<Company>XXX</Company>', body)
Result
<Company>XXX</Company>
Example: Replacing all company codes with 'XXX' using regex pattern.
Features
- Replace patterns using any valid regular expression in any Content
- Works with message body, context, or results from other Formula functions
- Combine with other Formula functions for powerful, layered expressions
- Use in Log Views for filtering, grouping, and self-service diagnostics
Important
The replaceregex plugin loads the entire message into RAM. Only use this function on small messages to avoid performance issues.
How to use the replaceregex Formula
- Select Formula as the expression type plugin.
- Enter your replaceregex expression in the 'Expression' text area.
- Provide the regex pattern, new value, and Content parameter (for example, the message body, a context value, or another formula result).
Syntax
- Replace pattern in message body:
replaceregex('Pattern', 'NewValue', body)
- Replace pattern in message context:
replaceregex('Pattern', 'NewValue', context('MessageContextKey'))
- Replace pattern in another formula:
replaceregex('Pattern', 'NewValue', SomeOtherNestedFormulaFunction(Content))
Next Step
How to Add or manage Search Fields
How to Add or manage Log Views
Related Topics
- 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?