
KB No. 1924: REGULAR EXPRESSIONS (REGEX)
Regular expressions allow you to manage exceptions on targeted URLs in filtering policies.
REGEX (or Regular Expressions) allow you to create patterns as needed.
REGEX can be used in the Policies and URL Lists menus, or when editing categories in the URL Filtering section.
Create REGEX
REGEX are defined as follows:
.: any symbol
*: repetition symbol: 0, 1, or more times the preceding symbol
and therefore:
.* matches any string of characters
a: the letter a
[abc]: the letter a or b or c
+: repetition symbol: 1 or more times the preceding symbol
?: repetition symbol: 0 or 1 time the preceding symbol
^: start of the character string
$: end of the character string
(): to group symbols
|: logical symbol "or"
\: protects a character (for example, allows you to insert a "." as a character rather than as "any symbol")
Examples:
- door (coat): matches door and coat rack but not coat
- [bB]boat: matches boat and Boat
- (chair|door) matches chair or door
- mysite.com: matches mysite.com but not mysiteX.com
- .*yahoo.*: matches all URLs containing yahoo
- www\.yahoo\..*: matches all addresses beginning with www.yahoo. (Examplewww.yahoo.fr, www.yahoo.com, etc.)
Useful websites:
http://www.annuaire-info.com/outil-referencement/expression-reguliere/http://regex101.com/