We use cookies on our website to ensure we provide you with the best experience on our website. By using our website, you agree to the use of cookies for analytics and personalized content.This website uses cookies. More Information
It seems like your browser didn't download the required fonts. Please revise your security settings and try again.
Reference / FAQ
Reference / FAQ

Regular Expressions

  • Last updated on

A regular expression is a combination of characters or character classes and operators that describe text for matching purposes. Regular expressions are like wildcards, only more powerful. With the Barracuda Email Security Service, you can use regular expressions in many of its block/allow features.

Matches are not case-sensitive. All regular expressions are lowercase before use as is the text against which expressions are matched. For this reason, you cannot use capital letter character classes.

Take caution when using special characters including |, *, '.' which are not taken literally unless escaped with a preceding backslash '\' character.

Operators

Operators recognized by the Barracuda Email Security Service in regular expressions include:

* zero or more times
+ one or more times
? zero or one time
| or
( ) grouping

Character Classes

A character class matches a character or range of characters listed between brackets '[' and ']'. Use a dash '-' to specify a range of characters. Use the '^' character inside the brackets '[' and ']' to negate a class. Some examples are:

.

any character except newline
[ac]

one of the following characters:  a A c C

[^ac]

anything but the characters 'a', 'A', 'c', 'C'

[a-z]

letters 'a' through 'z' regardless of case

[a-z.]

letters 'a' through 'z' or 'A' through 'Z' or a dot

[a-z\-]

any alphabetic character or a dash

\d

digit, shortcut for [0-9]

[^\d]

non-digit

\w

part of word: shortcut for [A-Za-z0-9_]

[^\w]

non-word character

\s

space character: shortcut for [ \n\r\t]
[^\s] non-space character

Miscellaneous Characters

^

beginning of line

$

end of line

\b

 

word boundary

\t

tab character

Special Characters

The following characters have a special meaning in regular expressions on the Barracuda Email Security Service and are prepended by a backslash '\' character when they are interpreted literally:

. [ ] \ * ? $ ( ) | ^ @

Examples

\bcialis\b

matches cialis, but not specialist

p[^\w]?h[^\w]?a[^\w]?r[^\w]?m[^\w]?a[^\w]?c[^\w]?y matches pha,rmacy or P.harm-acy
viagra

matches viagra, VIAGRA or vIaGRa

\d+

matches 1 or more digits: 0, 42, 007

(bad|good) matches the letters 'bad' or matches the letters 'good'
^free matches the letters 'free' at the beginning of a line
v[i1]agra

matches viagra or v1agra

v(ia|1a)gra matches viagRA or v1agra
v\|agra matches v|Agra, V|Agra, v|agRa, etc.
v(i|1|\|)?agra matches vagra, viaGra, v1agrA, V|AGRA, etc.
\*FREE\*

matches *FREE*, *frEE*, etc.

\*FREE\* V.*GRA matches *FREE* VIAGRA, *Free* VEHiCLegrA, etc.

 

 

Last updated on