Regular Expressions =================== For some of the configuration options, a rudimentary knowledge of Perl- style regular expressions will help you run Majordomo through its tricks. A regular expression is a concise way of expressing a pattern in a series of characters. The full power of regular expressions can make some difficult tasks quite easy, but we will only brush the surface here. The character / is used to mark the beginning and end of a regular expression. Letters and numbers stand for themselves. Many of the other characters are symbolic. Some commonly used ones are: \@ the `@' found in nearly all addresses; it must be preceeded by a backslash to avoid errors in Perl . (period) any character * previous character, zero or more times; note especially... .* any character, zero or more times + previous character, one or more times; so for example... a+ letter "a", one or more times \ next character stands for itself; so for example... \. literally a period, not meaning "any character" ^ beginning of the string; so for example... ^a a string beginning with letter "a" $ end of the string; so for example... a$ a string ending with letter "a" Example 1 --------- /foo\.example\.com/ Notice that the periods are preceded by a backslash so that they are interpreted as periods, rather than wildcards. This matches any string containing: foo.example.com such as: foo.example.com bar.foo.example.com user@bar.foo.example.com users%bar.foo.example.com@example.com Example 2 --------- /johndoe\@.*foo\.example\.com/ The `@' has special meaning to Perl and must be prefixed with a backslash to avoid errors. The string ".*" means "any character, zero or more times". So this matches: johndoe@foo.example.com johndoe@terminus.foo.example.com ajohndoe@terminus.foo.example.com@example.com But it doesn't match: johndoe@example.com brent@foo.example.com Example 3 --------- /^johndoe\@.*cs\.example\.org$/ This is similar to Example 2, and matches the same first two strings: johndoe@foo.example.org johndoe@terminus.foo.example.org But it doesn't match: ajohndoe@terminus.foo.example.org@example.com ...because the regular expression says the string has to begin with letter "j" and end with letter "g", by using the ^ and $ symbols, and neither of those is true for ajohndoe@terminus.foo.example.org@example.com. Example 4 --------- /.*/ This is the regular expression that matches anything. Example 5 --------- /.\*johndoe/ Here the * is preceded by a \, so it refers literally to an asterisk character and not the symbolic meaning "zero or more times". The . still has its symbolic meaning of "any one character", so it would match: a*johndoe s*johndoe Because the . by itself implies one character, it would not match: *johndoe Example 6 --------- Normally all matches are case sensitive; you can make any match case insensitive by appending an `i' to the end of the expression. /example\.com/i This would match example.com, EXAMPLE.com, ExAmPlE.cOm, etc. Removing the `i': /example\.com/ ...would match example.com but not EXAMPLE.com or any other capitalization. To be on the safe side put a \ in front of any characters in the regular expressions that are not numbers or letters. In order to put a / into the regular expression, the same rule holds: precede it with a \. Thus, with \ in front of the / and = characters, this: /\/CO\=US/ ...matches /CO=US and may be a useful regular expression to those of you who need to deal with X.400 addresses that contain / characters.