Let's imagine that previously you have created product cards and pulled data to them with Smart option.
Now we’re ready to adapt the values obtained from the websites to suit our needs.
When your product card is ready and smart option is set up, you will find this button (Direction Rule) for each variable under the settings:
When you click on it, the settings panel opens, allowing you to add the required Selector and Attribute (if you need to manually extract information from a website). After that, additional options for adding an Expression and a Format will appear.
Let’s take a look at how you can modify or format the extracted data — for example, trimming parts of it, changing values, adding extra text, or rounding, grouping, and appending symbols to prices.
Expressions
First, I'm going to familiarize you with the Expression field.
When you click on arrow sign, the automatic list with some predefined options will be visible for you. You can click on any of them to find the most suitable for you:
We can change the symbol to another one (for example we replaced $ sign to USD):
We can trim text to a certain number of characters with this expression –
(.{0,*})(.{0,}) where the star means how many symbols will remain (including spaces and any symbols) with Replacement – $1Please be aware, it works only for numbers, not for letters.
To add the missing protocol to the link, we can use
Modifier – ^// (if text starts with "//").
Replacement – https://
To change the path in a link, for example, if the image link starts with /image/
then we replace /image/ with http://rockway.biz/image/
Modifier – /image/
Replacement – http://rockway.biz/image/
Insert the content inside the got content with the expression ^(.*)$ and replace with own information (TEXT_BEFORE $1 TEXT_AFTER) -
Additionally, we can completely remove $ sign from the price with expression ^\$ and replace is empty:
Additionally, for each Expression you can see the Global control:
The global option means that the replacement will be applied to all matching occurrences found in the input.
If the global option is not enabled, only the first occurrence will be replaced.
Example:
Given the value $$$$ and a replacement of $ with usd:
With global enabled →
usdusdusdusdWithout global →
usd$$$
If you didn't familiar with regular expressions at this moment, I recommend you to use this resource to read about and this one to try and test it in a practice way.
Format fields
Let's consider one more useful option and try to round, group, or add some symbols to our data.
The fields of Format give us such a possibility.
By the way, these fields work only with data consisting of numbers with no spaces.
(actually, that is why we've considered the Modifier field firstly)
1. Simple Decimals
We will delete $ sign first and use our formula:
The Format field is #######.### - outputted result is 202.97
There are 11 Special Pattern Characters, but we'll cover the most important ones:
0 – prints a digit if provided, 0 otherwise
# – prints a digit if provided, nothing otherwise
. – indicate where to put the decimal separator
, – indicate where to put the grouping separator
The Format field is 0000.000 - outputted result is 0202.970
If the pattern is bigger than the number, zeros get added, while hashes get dropped, both in the integer and in the decimal parts.
2. Rounding
If the decimal part of the pattern can't contain the whole precision of the input number, it gets rounded.
Here, the 202.97 part has been rounded to 203:
The Format field is #.# - outputted result is 203
The same result will be with # only, because 202.97 will round to 203.
The Format field is # - outputted result is 203
3. Grouping
The grouping separator is used to specify a sub-pattern which gets repeated automatically (#,###.#)
Draw your attention to the fact that the Separator will be set as a dot by default, and after it has been set once after the first three symbols - it will be repeated after every three characters in a result.
The Format field is 0000,000.## and the Separator field is empty - outputted result is 0.000.202.97
All the extra zeros in left were added only to show how the separator will be displayed with bigger numbers.
Also, you can set any symbol as the Separator (in my example, I've used the dash)
The Format field is 0000,00 and the Separator field is dash - outputted result is 00-02-03
4. Mixing String Literals
It's possible to mix String literals within the pattern:
The Format field is "The # number" - outputted result is "The 203 number"
It's also possible to use special characters as String literals through escaping:
The Format field is "The '#' #th" - outputted result is "The # 379th"
And of course, we can combine all considered options in one formatting template:
(just for example "The '#' 0,000.# !!!" ):
Thank you for taking the time to read our articles. We hope you will find this information helpful.
If you have any additional questions, please email us at support@stripo.email.
We would be glad to talk with you.
















