Contents/Index/Search Download Complete PDF Send Feedback Print This Page

Previous

Regular Expressions

In This Section

Regular Expression Syntax

Using Non-Printable Characters

Using Character Types

Regular Expression Syntax

Metacharacter

Name

Description

\

Backslash

escape metacharacters

non-printable characters

character types

[ ]

Square Brackets

character class definition

( )

Parenthesis

subpattern, to use metacharacters on the enclosed string

{min[,max]}

Curly Brackets

min/max quantifier

{n} - exactly n occurrences

{n,m} - from n to m occurrences

{n,} - at least n occurrences

.

Dot

match any character

?

Question Mark

zero or one occurrences (equals {0,1})

*

Asterisk

zero or more occurrences (equals {0,})

+

Plus Sign

one or more occurrences (equals {1,})

|

Vertical Bar

alternative

^

Circumflex

anchor pattern to beginning of buffer (usually a word)

$

Dollar

anchor pattern to end of buffer (usually a word)

-

hyphen

range in character class

Note for the asterisk:

  • When using regular expressions, the asterisk is a metacharacter that means zero or more instances of the preceding character
  • When not using regular expressions, the asterisk is a wildcard, for any character, zero or more number of instances

For example, to block any domain that ends with "example.com" (such as www.example.com)

For a regular expression enter:
.*\.example.com

For a wildcard enter:
*.example.com

Using Non-Printable Characters

To use non-printable characters in patterns, escape the reserved character set.

Character

Description

\a

alarm; the BEL character (hex 07)

\cx

"control-x", where x is any character

\e

escape (hex 1B)

\f

formfeed (hex 0C)

\n

newline (hex 0A)

\r

carriage return (hex 0D)

\t

tab (hex 09)

\ddd

character with octal code ddd

\xhh

character with hex code hh

Using Character Types

To specify types of characters in patterns, escape the reserved character.

Character

Description

\d

any decimal digit [0-9]

\D

any character that is not a decimal digit

\s

any whitespace character

\S

any character that is not whitespace

\w

any word character (underscore or alphanumeric character)

\W

any non-word character (not underscore or alphanumeric)

 
Top of Page ©2013 Check Point Software Technologies Ltd. All rights reserved. Download Complete PDF Send Feedback Print