1. Handlebars Helpers
  2. Find and Replace

Handlebars Helpers

Find and Replace

Does a Regular Expression Find and Replace

Uses

  • Use to replace a word in some text with another word
  • Use to replace a word in some text with another word using a regular expression

Usage

Helper name : find_and_replace

Parameter Description
1 The regular expression to search for
2 The replacement text
TIP

Use regex101.com to test your regular expressions.

Examples

Simple Example

Example definition:

Replace apple with orange.

editor
        {
    "tasktype": "savedata",
    "params": {
        "fieldname": "replacement_text",
        "savevalue": "{{#find_and_replace "/apple/gi" "orange"}}There are apples and pears{{/find_and_replace}}"
    }
}

      

Substituted definition

loading...

Multiline usage

Add the regex flag m to enable multiline mode.

editor
        {
    "tasktype": "savedata",
    "params": {
        "fieldname": "replacement_text",
        "savevalue": "{{#find_and_replace "/(apple|pear)/gmi" "orange"}}There are apples and pears.\nThere are many apple baskets and pear baskets{{/find_and_replace}}"
    }
}

      

Substituted definition

loading...