Job Runner

Replace Strings with Specified Regular Expressions

Overview

Replace the part of the field value that matches the Regular Expression with another String.

Usage

If you perform this Do, the field value is changed from its original value, and records are reserved for saving. Updated records are not saved immediately but automatically after all actions in the job are finished. Use Save Modified Record to save the updated records at a different time.

You will need an API Token with the edit record permission for the app when autosaving. Make sure to Set Kintone API Token in another action and set the API Token for the Kintone app, if you want to save the Modified Source Record at a different time.

Parameters

Set Record, Field, Regular Expression, Replace String, and How Handle Multiple Hits.

Record

Select the Action you used to import the target records.

If multiple records are included, it is processed for each record. If there are no records, nothing is done.

Field

Use this parameter to select the field that holds the string value you want to replace. You can select multiple fields. When multiple fields are selected, the Action will simultaneously replace the target string in all fields.

This parameter accepts the following field types:

  • Text
  • Text area
  • Rich text
  • Link

You cannot include fields that are within a table.

Regular Expression

Enter a regular expression.

Example:

(\d+)-(\d+)-(\d+)

Replace String

Enter a string to replace the hit part.

If you leave this parameter empty, the Action will simply remove the string specified in Replace String.

\1 \2 … and so on, with partial match Strings caught by parentheses () in the Regular Expression. Kintone App Customize version of “Correct Use Conditional Expressions to Replace values in the field, such as $1 $2, but note that the Job Runner version will write \1 \2 … differently.

Example: Replace matched parts of a regular expression with parentheses. (Do not start with “=” because it is not an expression.)

\1year \2month\3day

Example: Replace with the result of another action. (When using a Customine expression, start with “=”.)

=$1

How Handle Multiple Hits

Choose what to do if the target field contains multiple instances of the string specified in String before Substitution. You can select between Replace All and Replace Only First One.

Select Replace All if you want to replace all instances of the string specified in String before Substitution.

Select Replace Only First One if you only want to replace the first instance of the string (the string closest to the beginning of the field value).

Understanding how it works compared to previous versions

Customine version 1.161 (released February 10, 2022) changes behavior. For compatibility, anything prior to 1.160 (released January 27, 2022) can still be used under the Name Replace by Regular Expression. The difference in behavior between the old and new versions is as follows:

  • The Regular Expression metacharacter ^ $ is treated differently.
    • 1.160 or earlier (old) … ^ matches the beginning of a sentence, $ matches only the end of a sentence, not the end of a line.
    • 1.161 and later … ^ matches beginning of line in addition to beginning of sentence, $ matches end of line in addition to end of sentence. (Multiline mode)

Precautions

  • Regular Expression matching, replacement processing uses Python standard re.sub. The fine-grained behavior of Regular Expressions, such as the available special characters, depends on the Python specification.