|
NewsBin Regular Expression Parsing Capabilities
The
"Find in Subject" field ("Subject Filter" in 3.22) allows
use of regular expressions as described here. The filename and subject
filters under the "Spam Filters" option (3.3) uses DOS style filters
like *.jpg or *somefile*.
Following are
some of the characters used in regular expression pattern matching
and their function. NewsBin forces all patterns to be case independent.
This is by no means an exhaustive list of regular expression
commands. There have been entire books written on the subject.
This merely touches on some of the commands that are most likely used for
the type of filters our users may apply to subject headers.
We've
attempted to create practical examples. If you have a good regex
you'd like to share, send email to tech_support@newsbin.com
and we may include it here as an example.
Commonly used commands
| Character |
Function |
| . |
Matches any single character |
| * |
Matches zero or more occurrences of
the preceding character or set. |
| + |
Matches one or more occurrences of the
preceding character |
| ? |
Matches zero or one occurrence of the
preceding character |
| ^ |
Matches starting at the beginning of
the line. Also acts as NOT when inside a Set. |
| $ |
Matches at the end of a line |
| [ab] |
Set. Matches the single character 'a' or 'b'.
If the dash '-' character is included, it must immediately be followed by the
bracket ']', otherwise it specifies a range like [a-z]. If the closing bracket ']' character is to be included, it must be
preceded by a quote. |
| [a-z] |
Range. Matches a single character in the range 'a'
to 'z'. Ranges and sets may be combined within the same set of brackets |
| ' |
Quote. Makes the next character a regular
(nonspecial) character. Note that to match the quote character itself, it must be
quoted. |
Examples NOTE: These are
described as they work in NewsBin which means a subject is displayed in the post
list if the pattern exists anywhere the subject of a post.
| Pattern |
Will Match |
Will Not Match |
Explanation |
| [.]r[a0-9][r0-9] |
file.rar,
file.r01, file.r02 |
file.dat |
Match a
".", then an "r", then either an "a" or the
number 0 through 9, then an "r" or the number 0 through 9. |
| jana[0-9][0-9]?[.]jpg |
jana1.jpg,jana01.jpg,jana12.jpg |
janabanana.jpg,
jana.jpg |
Match the
string "jana" followed by a number 0 through 9, then 0 or 1
number between 0 through 9. |
| ^re |
re:
some msg |
different |
Match the
string "re" only if it is at the beginning of a line. |
| er$ |
differ,
super |
different |
Match the
string "er" only if it is at the end of a line. |
| a |
a |
any string
containing know "a" characters |
Match the
letter "a". |
| a. |
a., ax,
a1 |
bc, hola,
yo |
Match the
letter "a" followed by any other character. |
| a?c |
ac, c,
acrobat, crow |
abc, abbc |
Match 0 or 1 occurrences
of the letter "a" followed by the letter "c". |
| a*c |
ac, aaac,
c, acrobat |
a, ab |
Match 0 or
more occurrences of the letter "a" followed by the letter
"c". |
| a+c |
ac, aac |
c |
Match
1 or more occurrences of the letter "a" followed by the letter
"c". |
| a* |
a, aaaa |
nothing |
Match 0 or
more occurrences of the letter "a". |
| a[b-z]c |
abc,
acc, azc |
abd, aac,
azz |
Match an
"a", followed by any character between "b" and
"z", followed by a "c". |
| [ab0-9]x |
ax, bx,
0x, 9x |
zx |
Match one
character which is either an "a", "b", or 0 through 9
followed by an "x". |
| a[-.]b |
a-b, a.b |
ab, a+b |
Match an
"a" followed by either a "-" or a ".",
followed by a "b". |
| a[^a-z]b |
a0b,
a.b, a@b |
aab, azb,
aa-b |
Match an
"a" followed by any character other than an "a"
through "z", followed by a "b". |
| ([0-9][0-9]?/[0-9][0-9]?) |
(1/1),
(19/24) |
[1/1],
(001/323) |
Match a
"(", followed by a number between 0 and 9, followed by 0 or 1
occurrences of the number 0 through 9, followed by a "/", followed
by a number between 0 and 9, followed by 0 or 1 occurrences of the number
0 through 9, followed by a ")" |
|