Technical data

8. Documentation for Developers
IPADDR: Let’s have a look at an example with an IP4-address. An ipv4 address consists of
four “Octets”, divided by dots (“.”). An octet is a number between 0 and 255. Let’s define an
octet at first. It may be
a number between 0 and 9: [0-9]
a number between 10 and 99: [1-9][0-9]
a number between 100 and 199: 1[0-9][0-9]
a number between 200 and 249: 2[0-4][0-9]
a number between 250 and 255: 25[0-5]
All are alternatives hence we concatenate them with forming one expression: “[0-9] [1-
9][0-9] 1[0-9][0-9] 2[0-4][0-9] 25[0-5]” and get an octet. Now we compose an IP4 address, four
octets divided by dots (the dot must be masked with a backslash, because else it would represent
an arbitrary char). Based on the syntax of an exp-file it would look like this:
OCTET = '[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]'
IPADDR = '((RE:OCTET)\.){3}(RE:OCTET)'
Assistance for the Design of Regular Expressions
If you want to design and test regular expressions, you can use the “regexp” program located
in the unix or windows directory of the package “base”. It accepts the following syntax:
usage: regexp [-c <check dir>] <regexp> <string>
The parameters explained in short:
<check dir> is the directory containing check and exp les. These are read by “regexp”
to use expressions already defined there.
<regexp> is the regular expression (enclosed in '...' or "..." if in doubt, with double
quotes needed only if single quotes are used in the expression itself)
<string> is the string to be checked
This may for example look like here:
./i586-linux-regexp -c ../check '[0-9]' 0
adding user defined regular expression='[0-9]' ('^([0-9])$')
checking '0' against regexp '[0-9]' ('^([0-9])$')
'[0-9]' matches '0'
./i586-linux-regexp -c ../check '[0-9]' a
adding user defined regular expression='[0-9]' ('^([0-9])$')
checking 'a' against regexp '[0-9]' ('^([0-9])$')
regex error 1 (No match) for value 'a' and regexp '[0-9]' ('^([0-9])$')
./i586-linux-regexp -c ../check IPADDR 192.168.0.1
using predefined regular expression from base.exp
adding IPADDR='((RE:OCTET)\.){3}(RE:OCTET)'
('^(((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]))$')
'IPADDR' matches '192.168.0.1'
298