This element allows you to additionally format the data entered by the user into the form. This block is hidden in the form and the user does not see it.
The following formatting actions are currently available:
- Find and replace
- Find and replace by regular expression
- Cut by regular expression
- Cut the specified number of characters
- Select non-empty values
- Register change
You can add multiple actions that will be launched one after another.
Find and replace
This function searches for specified characters in the input data for formatting and replaces them with the necessary ones. For example, you can easily cut out the country code in a phone number by specifying the characters “+49” in the “What to search for” field and an empty value in the “What to replace with” field.
Find and replace by regular expression
This function is similar to the previous one, but the search for symbols is performed using a regular expression. It is intended for experienced users and allows more flexible data formatting using special values.
As an example, let's write a regular expression that will also cut the country code from the phone in international format, i.e. the phone will be written in this format - +380 (50) 123 23 34
Using a regular expression, we will cut out all the characters up to the parentheses. To do this, we will write the following regular expression - /^\+[^\(]+/
Read more about regular expressions here .
Cut by regular expression
This function is similar to the previous one, except that it does not replace one data with another, but cuts out characters that match the regular expression.
As an example, let's write a regular expression that will strip the site domain from the passed link.
Having a link of the form - https://mysite.com/path/page.html,
we will cut out only the domain - mysite.com
To do this, we write the following regular expression - /^https*:\/\/(.+?)(\/|$)/ and the substring number - 1
Read more about regular expressions here .
Cut the specified number of characters
Using this function, you can cut the required number of characters in a string starting from a specified position.
In the image above, we cut out the first 10 characters of the string. The numbering of characters in the string starts from 0. That is, the first character in the string has position - 0.Some examples of using this feature:
- Cut last 2 characters at the end of the string. Start position -2, character count 0 or 2
- Cut all characters from 5 to the end of the line. Start position 4, character count 0
As you can see, if you specify 0 in the “Number of characters” field, it will use the remaining number of characters until the end of the line.
Select non-empty values
This function allows you to select only non-empty values from several fields specified in the settings.
Here you specify the list of fields from which non-empty values will be selected, and you can also configure the method for selecting values: select all non-empty values or only the first non-empty value. If all non-empty values are selected, you can additionally configure the separator with which the values will be merged. It is also possible to specify a default value that will be used if all field values are empty.
Change case
This function allows you to change the register of the input data. There are several modes of changing the register:- Lower case
- Upper case
- Every word is capital letter
- First capitalizated word
In one data formatting block, you can configure several actions that will be launched one after another.