Você está na página 1de 4

RegEx Language

Blue Coat Data Loss Prevention appliance Models DLP700/ DLP1700/ DLP2700

RegEx Language

The following list shows the standard PERL-compatible regular expressions that are supported by the DLP appliance in match rules. Table 1: Regular Expressions Supported by the DLP appliance RegEx
.

Description
Matches an arbitrary character, but not a newline. Matches the preceding pattern element one or more times.

Example (Note that all the if statements return a True value)


$string1 = "Hello World\n";if ($string1 =~ m/...../) { print "$string1 has length >= 5\n";} $string1 = "Hello World\n";if ($string1 =~ m/l+/) { print "There are one or more consecutive l's in $string1\n";}<B>Output:</B>There are one or more consecutive l's in Hello World $string1 = "Hello World\n";if ($string1 =~ m/H.?e/) { print "There is an 'H' and a 'e' separated by "; print "0-1 characters (Ex: He Hoe)\n";} $string1 = "Hello World\n";if ($string1 =~ m/el*o/) { print "There is an 'e' followed by zero to many"; print "'l' followed by 'o' (eo, elo, ellow, elllo)\n";}

Matches zero or one times.

Matches zero or more times.

RegEx Language

RegEx
{M,N}

Description
Denotes the minimum M and the maximum N match count. Denotes a set of possible character matches. Separates alternate possibilities. Matches a word boundary. Matches alphanumeric, including "_". Matches a nonalphanumeric character. Matches a whitespace character (space, tab, newline, form feed). Matches anything BUT a whitespace.

Example (Note that all the if statements return a True value)


$string1 = "Hello World\n";if ($string1 =~ m/l{1,2}/) { print "There exists a substring with at least 1"; print "and at most 2 l's in $string1\n";} $string1 = "Hello World\n";if ($string1 =~ m/[aeiou]+/) { print "$string1 contains one or more vowels.\n;} $string1 = "Hello World\n";if ($string1 =~ m/(Hello|HI|Pogo)/) { print "At least one of Hello, Hi, or Pogo is "; print "contained in $string1.\n";} $string1 = "Hello World\n";if ($string1 =~ m/llo\b/) { print "There is a word that ends with 'llo'\n";} else { print "There are no words that end with 'llo'\n";} $string1 = "Hello World\n";if ($string1 =~ m/\w/) { print "There is at least one alphanumeric "; print "character in $string1 (A-Z, a-z, 0-9, _)\n";} $string1 = "Hello World\n";if ($string1 =~ m/\W/) { print "The space between Hello and "; print "World is not alphanumeric\n";} $string1 = "Hello World\n";if ($string1 =~ m/\s.*s/) { print "There are TWO whitespace characters, which may"; print " be separated by other characters, in $string1";} $string1 = "Hello World\n";if ($string1 =~ m/\S.*S/) { print "There are TWO non-whitespace characters, which"; print " may be separated by other characters, in $string1";} $string1 = "99 bottles of beer on the wall. ";if ($string1 =~ m/(\d+)/) { print "$1 is the first number in '$string1'\n";}<B>Output:</B>99 is the first number in '99 bottles of beer on the wall. ' $string1 = "Hello World\n";if ($string1 =~ m/\D/) { print "There is at least one character in $string1"; print " that is not a digit.\n";} $string1 = "Hello World\n";if ($string1 =~ m/^He/) { print "$string1 starts with the characters 'He'\n";} $string1 = "Hello World\n";if ($string1 =~ m/rld$/) { print "$string1 is a line or string"; print "that ends

[]

\b

\w

\W

\s

\S

\d

Matches a digit, same as [0-9].

\D

Matches a non-digit.

^ $

Matches the beginning of a line or string. Matches the end of a

RegEx Language

line or string. [^] Matches every character except the ones instide brackets.

with 'rld'\n";} $string1 = "Hello World\n";if ($string1 =~ m/[^abc]/) { print "$string1 does not contain the characters "; print "a, b, and c\n";)

Since many ranges of characters depend on the chosen locale setting (e.g., in some settings letters are organized as abc..yzABC..YZ while in some others as aAbBcC..yYzZ) the POSIX standard defines some classes or categories of characters as shown in the following table, which is not supported by the DLP appliance. Table 2: POSIX Classes NOT Supported by the DLP appliance POSIX class
[:upper:] [:lower:] [:alpha:] [:alnum:] [:digit:] [:xdigit:] [:punct:] [:blank:] [:space:] [:cntrl:] [:graph:] [:print:] [^ \t\n\r\f\v] [^\t\n\r\f\v]

similar to
[A-Z] [a-z] [A-Za-z] [A-Za-z0-9] [0-9] [0-9A-Fa-f] [.,!?:...] [ \t] [ \t\n\r\f\v] uppercase letters lowercase letters

meaning

upper- and lowercase letters digits, upper- and lowercase letters digits hexadecimal digits punctuation space and TAB blank characters control characters printed characters printed characters and space

Example: [[:upper:]ab] should only return the upper letters and 'a' 'b' lower.

RegEx Language

Você também pode gostar