Find and replace

Description

This operation allows you to search for specific patterns within your input data and replace them with new text.


Data types

These are the input/output expected data types for this operation:

Input data

- Text or data where you want to perform find-and-replace operations.

Output data

- Output strings after the find-and-replace operations.


Parameters

These are the parameters you need to configure to use this operation (mandatory parameters are marked with a *):

chevron-rightSubstring to find*hashtag

Enter the text or pattern you want to find in the input.

chevron-rightReplacement*hashtag

Enter the text with which you want to replace each match. You can use RegEx patterns here.

chevron-rightGlobal Match*hashtag

Set true if you want to replace all matches found. If this is set to false, only the first match will be replaced. The default value is true.

chevron-rightCase Insensitive*hashtag

Set true if you want to ignore case when matching. The default value is false.

chevron-rightMultiline*hashtag

Set true to enable multiline mode. This feature controls how to treat line breaks in the input. Specifically, it affects the behavior of the ^ and $ anchors in the RegEx patterns you use in the Substring to find parameter.

  • When Multiline is enabled:

    • ^ matches the start of a line, not just the start of the whole input.

    • $ matches the end of a line, not just the end of the whole input.

    • This means the regex treats the input as multiple lines, and you can match patterns at the beginning/end of each line.

  • When Multiline is disabled:

    • ^ and $ only match the start and end of the entire input, respectively.

    • This is useful for matching patterns that span across the whole input or aren't line-sensitive.

The default value is false.

Example

Example with Multidata activated:

Input data:

  • Substring to find - ^Error:.*

  • Replacement - ALERT

  • Multiline - true

Output data:


Example with Multidata deactivated:

Input data:

  • Substring to find - ^Error:.*

  • Replacement - ALERT

  • Multiline - false

Output data:

Because ^ only applies to the start of the whole input with multiline off, the pattern never matches.

chevron-rightDot Matches All*hashtag

Set true to match new line characters. Specifically, this affects how the . (dot) behaves in the RegEx patterns you use in the Substring to find parameter.

When Dot Matches All is enabled, the dot (.) also matches newline characters, allowing patterns to match across multiple lines.

The default value is false.

Example

Example with Dot Matches All activated:

Input data:

  • Substring to find - <start>.*<end>

  • Replacement - [BLOCK]

  • Dot Matches All - true

Output data:

.* includes newlines, so everything from <start> to <end> is matched and replaced.


Example with Dot Matches All deactivated:

Input data:

  • Substring to find - <start>.*<end>

  • Replacement - [BLOCK]

  • Dot Matches All - false

Output data:

.* does not match across newlines, so no match occurs.


Examples

Suppose you want to replace all the occurrences of the word "error" with "issue". To do it:

  1. In your Pipeline, open the required Action configuration and select the input Field.

  2. In the Operation field, choose Find and replace.

  3. Set Substring to find to error.

  4. Set Replacement to issue.

  5. Set Global Match to true.

  6. Set Case Insensitive to true.

  7. Set Multiline to false.

  8. Set Dot Matches All to false.

  9. Give your Output field a name and click Save. The count will be displayed in the output field.

circle-info

You can try out operations with specific values using the Input field above the operation. You can enter the value in the example above and check the result in the Output field.

In this example, given the following string:

you'll get this output:

Last updated

Was this helpful?