Get started
Get started

Regex and String Functions

String Functions

You may need to transform your data in order to get it from your input source to your output destination. Part of this will involve formatting the data – to enable your no-code application to correctly handle and display your records.

As described in previous guides, our integration partner, Integromat, can process your data as strings. These are discrete units of information in the form of text – Integromat collects these together as bundles.

Using Integromat, you can automatically format your data strings. Perhaps your data has been formatted in an unusual way due to it being stored by legacy software, or maybe you require you have a reason to have output data appear in a specific way.

For most functions, Integromat’s basic string functions will suffice for converting/creating data using predefined filtering rules:

String function example:

Suppose you have a lot of customer names, all stored in lowercase format, and you wish to convert them to proper case, to be used in an email form:
john smith -> John Smith

You could use the startcase function in a Set Value module to convert every instance of those records in a data bundle to a new string:

In the example above this is startcase(BUNDLE)

 

This will take each word in a given string and convert the first (start) character to upper case:

There are several of these converter functions available; see Integromat’s guide to string functions for a more in-depth explanation of them:

https://www.integromat.com/en/help/string-functions

Advanced – Regex

There may be instances where you need to specify a more complex rule. This is where “Regular Expressions” or “Regex” are used.

Regex is not a coding language.

Regex is just a means of filtering strings of text. It is a powerful tool and can be used to search for almost anything, from phone numbers to email addresses to instances of whitespace in blocks of text.

You can even use Regex in most word processor search boxes – to find, replace, or remove specific characters.

Example

You may have a spreadsheet containing currency values:
£12.34p

Suppose your accounting software integration requires the input data values to be expressed as just numbers.
You can use a regular expression to filter out all the non-numeric characters, in order to obtain the following result:
1234

For this example we will use a Transformer module, and a Set Value module to simulate the input:

We add and connect a Text Parser – Replace transformer module, and set the following expression as the string for the parser to match :
[^0-9]

Here, ^ indicates the string to search should NOT contain the characters immediately following it.

 

[…] contains the set of characters you wish to search a given string for.

 

As we want only numeric characters to be found, we’ll use the expression 0-9  to look for characters 0 through to 9 inclusive.

Next, we can use an Integromat string function to define the replacement value:
replace(emptystring)

Here, replace is the function that tells Integromat to replace the characters found in the search pattern with whatever is specified inside the brackets.

emptystring is a special Integromat function that essentially removes unwanted characters.

 

We set the input as the output from the Set Value module described above – in a real scenario you would use the output from another module.

As you can see, the output from the transformer is a string of only numbers:

Note: Some regex patterns include flags (such as /g) to indicate where to search in a string – Integromat uses the Global match: True setting instead.

The above example is obviously a specific case, but should give you an introduction to the general principles. We advise that you read up using the references linked below, and search the web for examples. Try using the Set Value module to simulate data input, to easily test how your regex strings work – some trial and error will be involved.

Here’s a handy primer to use as quick reference:

Resources:

Wikipedia article on Regex
https://en.wikipedia.org/wiki/Regular_expression

Quick Reference guide:
http://regexrenamer.sourceforge.net/help/regex_quickref.html

Helpful tool for trying out expressions:
https://regex101.com/
This site includes a library of common expressions.

Back to tutorials

Share this