Follow

Regex in Business Rules

Using regex in business rules

Business rules are the method to define how the Glia platform acts on clients' website. Some of the fields that can be filled out require special syntactical input - 'url' and 'path' field for example. The syntax inserted into those fields is known as 'regular expression' or 'regex' for short that Glia has limited and simplified a bit. That allows for a bit more complex and compact rules, that will try to match the inserted pattern.

Special regex characters and their meaning:

  • the pipe '|' stands for OR. Sample syntax:
business|rule

The above pattern will match either business OR rule, but not both.

  • the asterisk '*' stands for ALL. Sample syntax:
*glia*

The above pattern will match the word glia that occurs anywhere in the field.

  • the exclamation mark '!' stands for EXCLUDE and is used with parenthesis. Sample syntax:
(!(glia))

The above pattern will match anything BUT glia.

Examples

Case 1

Show ONLY team A operators in pages:

  • example.com/first
  • example.com/second 
  • example.com/second/third 
  • example.com/second?glia=1

The rule (shortest version): *first|second*. ONLY team A operators are shown in pages that have the URL that have the keyword 'first' or 'second' in it. This also includes pages like example.com/something/else?first for example as this URL contains the marked keyword 'first'. All the other teams operators INCLUDING team A operators are shown in other pages.

Can also be written as (longer version, same result): *first|second|second/third|second?glia=1*. ONLY team A operators are shown in pages that have the URL that has the keyword 'first' or 'second' or 'second/third' or 'second?glia=1' in it. This also includes pages like example.com/something/else?first for example as this URL contains the marked keyword 'first'. All the other teams operators INCLUDING team A operators are shown in other pages.

Screenshot_2019-06-27_at_15.11.51.png

Case 2

Show ONLY team A operators in pages defined in 'Case 1' and show ONLY team B operators in pages:

  • example.com/old
  • example.com/old/fresh

The rule for team A: *first|second*. Just like in the 'Case 1', ONLY team A operators are shown in the pages that have the keyword 'first' or 'second' in the URL.

The rule for team B: *new|old*. ONLY team B operators are shown in the pages that have the keyword 'new' or 'old' in the URL.

All the other pages, that do not have the keyword 'first, 'second', 'new' or 'old' in the URL, have both team A and team B operators shown.

Screenshot_2019-06-27_at_15.22.14.png

 

Case 3

Show ONLY team A operators in pages defined in 'Case 1' and show ONLY team B operators in ALL the other pages.

The rule for team A: *first|second*. This rule includes all the pages for team A that have the keywords 'first' or 'second' in the URL.

The rule for team B:(!*(first|*second))*. This rule includes all the pages for team B, except for the pages that have 'first' or 'second' in the URL. For example pages like example.com/glia, example.com/, etc.

Screenshot_2019-06-27_at_15.23.03.png

 

List of regex fields

The list of fields that have the regex capability, meaning you can use special characters like the asterisk '*' and the pipe '|':

  • Conditions -> Coming From field
    Screenshot_2019-05-30_at_16.09.34.png
  • Source -> Navigation field
    Screenshot_2019-06-27_at_15.24.18.png
  • Source -> Filling From (Input value field)
    Screenshot_2019-06-27_at_15.25.26.png

Differences from regular Ruby regex

Glia business rules fields accept only simplified regex so that:

  • character '*' is mapped to mark ALL instead of regular regex '.*'
  • character '!' is mapped to mark EXCLUDE instead of regular regex '?!'
  • the '^' (beginning of string) and '$' (end of string) characters are omitted in business rules.

To try and test out the rules, http://rubular.com/ online regex editor can be used.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments