Regular Expressions for Ptsfilter
On this page you will find the details necessary to custom make complex
regex patterns for ptsfilter rejection with examples. The four basic types
of metacharacters
used and listed for composing these patterns are: Single Metacharacters,
Quantifiers, Anchors and Escape Characters.
Single-Character Metacharacters:
. Matches any one character.
[...] Matches any character listed between the brackets.
[^...] Matches any character except those listed between
the brackets.
Examples:
c.t matches "cat" or "cot"
ca[sin]o matches "caso", "caio", "cano"
mo[^ne]y matches any word with "mo" and "y" in that
sequence except for the word "money"
Quantifiers:
* Matches the preceding element zero or more times.
The following are "extended" metacharacters which are not
available on system 5.4:
? Matches any character element zero or one times.
+ Matches the preceding element zero or one times.
{num} Matches the preceding element num times.
{min,max}Matches the preceding element at least min
times but no more than max times.
Examples:
ca?t matches "cat" or "caat"
ca*t matches "cat" or "cat" with any number of a's
b+ar matches "bar" or "baar"
la{3}rge matches "laarge" , "laaarge" or "laaaarge"
co{2,4}w matches "cooow" , "coooow" and "cooooow"
Anchors:
^ Matches at the start of the line.
$ Matches at the end of the line.
\< Matches elements at the beginning of a word.
\> Matches elements at the end of a word.
\b Matches any word boundary at the beginning or the end of a word.
\B Matches any position that isn't a word boundary at
the beginning or end of a word.
Example:
^boys are.. matches any string or line with "boys" at the beginning
..eating$ matches any string or line with "eating" at the end
\<book matches "bookmark" or any word that begins with "book"
\>book matches "handbook" or any other word that ends with "book"
\bmachine matches the word "machine" and the string its in
\Band matches "and" no matter where it appears in the
string(ie:"and" matches "hand" , "stand" , "standard")
Escape Character:
\ Escapes any one metacharacter from its special meaning.
Example:
\+ matches up a "plus" sign.(ie: + no longer matches
preceding element zero or one times)
Other Extended Metacharacters:
(..|..) Matches either word or phrase inside the parenthesis,
to that word or phrase included in a string.
EXAMPLE:
(wrench|ball) matches any string with either "wrench" or "ball" or
both in it
(phrase1|phrase2) matches any string with either/or phrase1 or phrase2
in it
Some good examples Of regular expression usage:
[a-z]{1,3}[a-z]{1,9} catches strings like v<!--748724-->iagra!
One users use of Ptsfilter and regular expressions
For more information about our software please contact us:
info@expertsinunix.com
, or call our offices at 410-838-5100.

|