How to work with strings

Browser Automation Studio supports arbitrary javascript execution, so you can process strings with javascript. However, there are some snipsets to accomplish most used tasks:

Starting from 12.0.0 version you can use expression editor to generate javascript. See this page I don't know javascript, what should I do



How to concat strings

Use “Set Variable” action and set “Value Of Variable” to [[VARIABLE1]][[VARIABLE2]], like this:


The concat result will hold VARIABLE1 + VARIABLE2 afterwards.

You can also place delimiter between them:



How to generate random string

Use “Set Variable” action and set “Value Of Variable” to rand(), also need to set field type to “expression”.

Use rand(20) to generate random string with length 20. Function without parameters will generate string with length 10.

Field type expression treats data not as string, but as javascript code and rand is javascript function.



How to split line into pieces

You can split line in 2 ways: by using “Parse Line” function, or with javascript split function.

Using “Parse Line” is quite straightforward, input line to parse and list of resulting variables, which is separated by commas:


The advantage of this method is that “Parse Line” understand different delimiters.

Another way is to use split function.

Use “Set Variable” action and set “Value Of Variable” to [[VARIABLE_TO_SPLIT]].split(":")[0], also need to set field type to “expression”:

You can use split several times, for example, if you have url string like "http://google.com/?key1=val1&key2=val2&key3=val3" and you want to extract key2 value, fill “Value Of Variable” to [[URL]].split("&")[1].split("=")[1]

How to execute regular expression

To execute regular expression, you need to use “Set Variable” action and set “Value Of Variable” to [[VARIABLE_TO_APPLY_REGEXP]].match(/\d+/)[0], also need to set field type to “expression”.

This regular expression will extract first number from string in variable VARIABLE_TO_APPLY_REGEXP.