Blog
The Blog

KB N°1924: REGULAR EXPRESSIONS (REGEX)

Olfeo On-Premise knowledge base
June 2, 2023

Regular expressions can be used to handle exceptions on URLs targeted in filtering policies.

REGEX (or Regular Expressions) are used to create patterns as required.

REGEX can be used in the Policies and URL Lists menus, or in the URL Filtering section of category editing.

Create REGEX

REGEX are defined as follows:

.. any symbol

*: repeat symbol: 0, 1 or more times the previous symbol

and therefore :

.* matches any string

a: the letter a

[abc]: the letter a or b or c

+: repeat symbol: 1 or more times the previous symbol

?: repeat symbol: 0 or 1 times the previous symbol

^: start of string

$: end of string

(): to group symbols

|: logical "or" symbol

\: to protect a character (e.g. to insert the "." as a character and not as "any symbol")

Examples:

  • porte(manteau): matches porte and portemanteau but not manteau
  • [bB]ateau: matche bateau and Bateau
  • (chair|door) matches chair or door
  • monsite\.fr: matches monsite.fr but not monsiteXfr.com
  • .*yahoo.*: matches all URLs containing yahoo
  • www\.yahoo\..*: matches all addresses starting with www.yahoo. (Example www.yahoo.fr, www.yahoo.com, ...)

Useful websites :

http://www.annuaire-info.com/outil-referencement/expression-reguliere/http://regex101.com/