VoyForums - Free messageboard services

[Home]

[Contribute]

[Create your own Forum]

[Categories]

[Owner Login]

[Search]

[Exchange]

[Help]

[FAQ]

[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):



Regular Expressions

Important: Crucial system performance issues forced us to make some changes. Bans can now only be placed on IP addresses (ie. 127.0.0.1) -- You cannot ban a hostname (ie. somecomputer.somewhere.com).

This applies only to read-bans. You may still ban hosts in your write-ban list.

  1. What is a Regular Expression?
  2. How do I use them for Access Restrictions?
  3. Examples

I. What is a Regular Expression?

Regular Expressions (regex's) are a wildcard pattern-matching tool used traditionally under Unix and Unix-like operating system utilities like grep, sed, awk, and recently Perl. Regex's are much more elaborate and powerful than standard wildcard expressions, but are much more complex. For the techies: A regex is a text string that describes a pattern used to represent a set of strings and can be represented by a Finite State Automaton (FSA); however, if you know what an FSA is you probably know what a regex is.

This section will only briefly describe what are known as General/Extended Regular Expressions as used in common applications and, in particular, those used by VoyForums. Full details can be found at other sites.

VoyForums uses Extended Regular Expression syntax to give users the most power.

Regular Expressions consist of sequences of characters with special meanings:

Ordinary Characters
Any characters (other than the following special characters) match the character itself.
Backslashed Characters
A backslash followed by any special character (called "escaping") matches the special character itself (also referred to as "no magic").
Periods (.)
A period (.) matches any character
Carat (^) and String ($)
A carat (^) at the beginning of the regex matches the start of a line, a string ($) at the end of a regex matches the end of the line.
Brackets ([])
If you enclose characters in brackets, any one (and only one) of these characters will be matched. If the first character is a carat (^) then it will match any characters other than those listed. Ranges of characters can be specified like [a-z] would allow any lowercase letter, while [a-zA-Z0-9] will allow any lowercase or capital letter as well as any digit.
Parentheses
Parentheses are used to allow "Back References" (which are beyond the scope of this document), a grouping of a sequence into one unit (known as an atom) as well as to provide a way of matching more than one sub-regex separated by pipes (|). For instance, the regex he (was|is) there would match both he was there as well as he is there.
Plus (+)
A plus (+) means the previous atom (character or parenthesised group) must be matched one or more times.
Asterisk (*)
An asterisk (*) means the previous atom may be matched zero or more times.

II. How do I use them for Access Restrictions?

VoyForums allows Forum Owners to restrict access to their Forum in order to prevent misuse. Currently this feature is accessable from the Advanced Configuration area.

In addition to the direct entry of Hosts/IPs and Wildcards allowed in this configuration (see the Access Restriction page for general information), VoyForums allows the use of Regular Expressions (regex's).

To use a Regular Expression one must simply prepend a slash (/) to the expression. Therefore, VoyForums will recognize /pattern as indicating that pattern is a regex. Example: /^198\.168.*$

There are a few things to note for regex's used in the Access Restrictions area:

  1. Do not add a trailing slash (/) - the first / is all that is necessary to specify that it is a Regular Expression.
  2. They are case insensitive.
  3. Just like the plain or wildcard entries, when a regex is found in the Access Restriction area, VoyForums decides it is a Host if it contains any letters in it. Otherwise it is considered an IP address. This is important because VoyForums needs to know whether or not it is comparing the match to a user's Hostname or IP address.
  4. They do not implicitly match to the beginning and end of the string, so saying /2 will match a 2 anywhere in the name, thereby probably banning many IPs one did not intend on banning. To specifically match IPs that start with a 2 or perhaps a 206 use /^2 or /^206, respectively.

III. Examples

Please note: When placing entries in a banlist, it is preferred to place a single hostnames or IP addresses (like "127.0.0.1 somehost.com 127.0.0.2 ..."). If multiple hosts or IPs are to be banned, use a wildcard if possible (like "127.0.0.* somehost.com *.otherhost.com"). Regular Expressions, due to their ugliness and complexity, should be used only when a plain Host/IP or Wildcard expression cannot handle what is desired.

The following table gives some example entries in your banlists. It should be evident that the Wildcard method is more-simple to use than the Regex method, but Regexes are more powerful. Please review all examples.

To ban... Wildcard equiv. Regex
Only the IP 192.168.38.2 192.168.38.2 /^192\.168\.38\.2$
Any IP starting with 192.168.38.2 192.168.38.2* /^192\.168\.38\.2
Any IP starting with 192.168 192.168.* /^192\.168\..*
Any IP ending with .200 *.200 /\.200$
Any Host ending with somedomain.com *.somedomain.com /\.somedomain\.com$
Any Host ending with somedomain.com *.somedomain.com /\.somedomain\.com$
Both foo.domain.com and bar.domain.com Not possible /^(foo|bar).domain\.com$
Only 192.168.38.1, 192.168.38.2, and 192.168.38.5 Not possible /^192\.168\.38\.[125]$
Only 192.168.38.1, 192.168.38.20, and 192.168.38.203 Not possible /^192\.168\.38\.(1|20|203)$
Any host from domain.com that starts with "pop" immediately followed by an optional number. This includes matching hosts like pop35foo.bar.domain.com Not possible /^pop[0-9]*.*\.domain\.com$
Any host from domain.com that starts with "pop" immediately followed by an optional number. This only matches pop#.domain.com Not possible /^pop[0-9]*\.domain\.com$

[ Back to Help Desk ]


VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.