Target with regular expressions

In iAdvize, from one single rule, you can target one or more pages that contain an object or a specific word thanks to regular expressions.

For example, a breadcrumb contains the different categories of a website.

The aim is to target the “anti-chute” and “solar” categories knowing that the custom data brings us back to: "Home> Products> Hair> Anti-chute care" for the first category and "Home> Products> Solar" for the second.

By using regular expressions, we can target these two categories with only one targeting rule.

  • In a targeting rule, use the condition "regex".
  • We'll use a simple regular expression with a logical OR (or | or SHIFT + ALT + L on the keyboard). This gives the following expression: "(anti-chute | solar)."

regexEN.png

 

Warning :
  • It is essential to have the parentheses and not to insert a space between the two objects (anti-chute and solar) nor following the parentheses to take the regular expression into account.
  • You can also use a regular expression to identify the presence of an element. In this case, if you want to know if the breadcrumb is empty or not, use the following regular expression: "(+)."

For more details, you can go to this website to test different expressions http://www.regexr.com/

For more information on this subject: