Regular Expressions
From Botnix
Contents |
Regular Expressions
Because botnix uses regular expressions as opposed to glob matching to match hostnames, normal hostnames with * and ? as match tokens will not work. This page will outline what you must change to make your glob hosts work correctly. Please note this is only the very basics of regular expressions. You should use google to find more in-depth material on them. A useful set of guides can be found here
'*' Symbol
In botnix, you must change the "*" in a hostmask to ".*?"
'?' Symbol
In botnix, you should change the "?" in a hostmask to a single "."
'.' Symbol
Because the dot character has special meaning in a regexp, you should use "\."
'$' Symbol
To signify that your pattern should always be the end of a string, place a $ on the end of it, like for example "\.com$" to match all hosts ending in ".com"
'^' Symbol
To signify that your pattern should always be at the start of a string, prefix the string with the ^ character, like for example ^foo to indicate that all hosts starting with foo should match.
'\d' sequence
To match a number, you can put the "\d" sequence into your pattern. This matches any one number such as "0" or "6".
'+' Symbol
Certain sequences such as \d and the [] and {} sequences allow you to place a + after them, so they for example become \d+. If you do this, instead of the previous sequence meaning 'one of' it now means 'one or more of', so for example \d+ means one or more numbers.
'{}' Symbols
The {} characters can be used to represent an exact count of something in your pattern. For example:
- \d{2} means two numeric characters
- \d{2,4} means anywhere between two and four numbers in a row
- \d{,4} means anything up to but not over four numbers in a row
- \d{3,} means at least three numbers in a row
'[]' Symbols
The [] symbols can be used to represent a character range in your pattern, forexample:
- [a-z] means any letters in the range a through z (note: you can use \w for this)
- [X-Z] means any letter through the range X to Z (inclusive)
NB: This sequence, and all regular expression sequences are CAsE sEnSiTiVe!
'|' Symbol
The | (pipe) symbol has special meaning in a regular expression so you should escape it and make it "\|" instead.
The actual pipe character can be used for alternation, for example, to specify that a pattern can either match 'dogs' or 'cats' but nothing else use the pattern:
- dogs|cats
Putting it all together
Here are some example 'glob' style hosts (from for example eggdrop) and their regexp counterparts as used by botnix.
- *!Boo@*.cpe.cable.rogers.com becomes ^.*?!Boo@.*?cpe\.cable\.rogers\.com$
- *.proxy.com becomes proxy\.com$
- *@brainbox* becomes .*?@brainbox
- *!socks@* becomes ^socks@
- *@ppp69.proweb.co.uk becomes .*?@ppp\d{,2}\.proweb\.co\.uk
- *@red.corp.net and *@blue.corp.net becomes one regular expression .*?@(red|blue)\.corp\.net$
As you can see, you only need to include as much as is neccessary to match the pattern to the host, the redundant *!*@ parts are not required.

