table of contents
other versions
- wheezy-backports 0.1-1~bpo70+1
- jessie 0.1-1
- testing 0.1.1-2
- unstable 0.1.1-2
RGXG(1) | User Commands | RGXG(1) |
NAME¶
rgxg - ReGular eXpression GeneratorSYNOPSIS¶
rgxg COMMAND [ARGS]DESCRIPTION¶
rgxg is a generator for (extended) regular expressions.COMMANDS¶
alternation [options] [PATTERN...]Generate a regular expression that matches any
of the given patterns.
Options
Examples
Match either lion, elephant, rhino, buffalo or leopard:
- -N
- Omit the outer parentheses, if any, of the regular
expression. This option can be useful if the generated regular expression
is used within another alternation.
- -h
- Display help and exit.
$ rgxg alternation lion elephant rhino buffalo leopard (lion|elephant|rhino|buffalo|leopard)
Generate a regular expression that matches all
addresses of the given CIDR block. Both IPv4 and IPv6 CIDR blocks are
supported.
Options
Examples
Match 192.168.0.0/24:
Match 2001:db8:aaaa:bbbb:cccc:dddd::/96 limited to lower case letters:
Match 2001:db8:1234::/48 restricted to uncompressed standard notation:
- -N
- Omit the outer parentheses, if any, of the regular
expression. This option can be useful if the generated regular expression
is used within another alternation.
- -l
- Match only IPv6 addresses with lower case letters. By
default both lower and upper case letters are matched.
- -U
- Match only IPv6 addresses with upper case letters. By
default both lower and upper case letters are matched.
- -u
- Do not match IPv6 addresses with zero compression (second
form of text representation of IPv6 addresses mentioned in section 2.2 of
RFC 4291).
- -s
- Do not match IPv6 addresses in mixed notation (third form
of text representation of IPv6 addresses mentioned in section 2.2 of
RFC 4291).
- -h
- Display help and exit.
$ rgxg cidr 192.168.0.0/24 192.168.0.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])
$ rgxg cidr -l 2001:db8:aaaa:bbbb:cccc:dddd::/112 2001:0?db8:aaaa:bbbb:cccc:dddd((::[0-9a-f]{1,4}|::|:0?0?0?0(::|:[0-9a-f]{1,4}))|:0.0(.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){2})
$ rgxg cidr -u -s 2001:db8:1234::/48 2001:0?[Dd][Bb]8:1234(:[0-9A-Fa-f]{1,4}){5}
Generate the regular expression which matches
the given string by escaping the escape characters.
Options
Examples
Match '1+(2*(3-4))':
- -h
- Display help and exit.
$ rgxg escape 1+(2*(3-4)) 1\+\(2\*\(3-4\)\)
Describe the usage of rgxg or the given
COMMAND.
Generate a regular expression that matches the
number range between FIRST and LAST. If LAST is omitted the regular expression
matches all numbers which are greater than or equal FIRST. The numbers must be
positive and given in base-10 notation.
Options
Examples
Match the numbers from 0 to 31:
Match numbers from 0 to 31 with base 2:
Match 0 to 31 with base 16:
Match 0 to 31 with base 16 limited to upper case letters:
Match 0 to 31 with base 16 limited to lower case letters:
Match 00 to 31:
Match 0000 to 0031:
Match 0 to 31 and 00 to 31 and 000 to 031:
Match 0 to 31 and omit outer parentheses:
Match all numbers greater than or equal to 4096:
- -b BASE
- Generate the regular expression for the number range with
base BASE. The BASE must be in the range between 2 and 32. The default
base is 10.
- -N
- Omit the outer parentheses, if any, of the regular
expression. This option can be useful if the generated regular expression
is used within another alternation.
- -l
- For bases greater than 10 only match lower case letters. By
default both lower and upper case letters are matched.
- -U
- For bases greater than 10 only match upper case letters. By
default both lower and upper case letters are matched.
- -h
- Display help and exit.
- -z
- Only match numbers with leading zeros. By default the
number of leading zeros depends on the length (i.e. the number of digits)
of LAST (see also -m). The default is to not match numbers with
leading zeros.
- -Z
- Match numbers with a variable number of leading zeros. By
default the maximum number of leading zeros depends on the length (i.e.
the number of digits) of LAST (see also -m). The default is to not
match numbers with leading zeros.
- -m LENGTH
- with -z or -Z, the minimum LENGTH of matched numbers. For instance the number 5 with LENGTH set to 3 and -z option set is matched as '005'. If LENGTH is lesser than or equal to the number of digits of LAST, this option has no effect.
$ rgxg range 0 31 (3[01]|[12]?[0-9])
$ rgxg range -b 2 0 31 (1[01]{0,4}|0)
$ rgxg range -b 16 0 31 1?[0-9A-Fa-f]
$ rgxg range -b 16 -U 0 31 1?[0-9A-F]
$ rgxg range -b 16 -l 0 31 1?[0-9a-f]
$ rgxg range -z 0 31 (3[01]|[0-2][0-9])
$ rgxg range -z -m 4 0 31 (003[01]|00[0-2][0-9])
$ rgxg range -Z -m 3 0 31 (0?3[01]|0?[0-2]?[0-9])
$ rgxg range -N 0 31 3[01]|[12]?[0-9]
$ rgxg range 4096 ([1-9][0-9]{4,}|[5-9][0-9]{3}|4[1-9][0-9]{2}|409[6-9])
Prints the version of the rgxg command.
EXIT STATUS¶
The exit status is 0 if the regular expression has been successfully generated. If an error occurred the exit status is 1.SEE ALSO¶
regex(7)AUTHOR¶
Hannes von Haugwitz <hannes@vonhaugwitz.com>April 14, 2013 | rgxg 0.1 |