Roboteka
Roboteka · Robots · Format string by regex

Format string by regex

The Format string by regex robot for Bitrix24 (Alaio) business processes runs a PHP preg_replace over the source string: it matches your regular expression and substitutes it with your replacement, where $0 is the whole match and $1, $2 are captured groups. It returns the transformed Result and a Success flag (false on a regex error).

Format string by regex is a text robot for Bitrix24 (Alaio) business processes and robots that gives you full regular-expression replacement (PHP preg_replace) right inside the workflow designer. You provide the source string, a pattern, and a replacement; the robot applies the pattern to the text and returns the rewritten value in the Result field. In the replacement you can reference the whole match as $0 and any captured groups as $1, $2, and so on, which lets you reorder, reformat, or extract parts of a value. A Success flag is also returned — it is false when the pattern is invalid, so you can branch safely instead of saving broken output. Use it to reformat phone numbers, normalize dates, strip or rearrange parts of a string, or extract a fragment from CRM data. No code deployment and no developer are required.

What input parameters does the robot accept?

Parameter Type Required? Default
Source string string yes
Regular expression (pattern) string yes
Replacement string ($1, $2 for groups) string

What does the robot return?

Parameter Type
Result string
Success (false if regex error) bool

Scenario: reformat a 10-digit phone into a readable mask.

  1. Step 1. Add the Format string by regex robot to your business process.
  2. Step 2. Set Source string to the field, e.g. {=Document:PHONE}.
  3. Step 3. Set the pattern and a replacement using groups, e.g. replacement "+1 ($1) $2-$3".
  4. Step 4. Use the Result field downstream, and check the Success flag in a condition.

Related robots

Related articles