|
NAMErgxg - ReGular eXpression GeneratorSYNOPSISrgxg COMMAND [ARGS]DESCRIPTIONrgxg is a generator for (extended) regular expressions.For instance it is useful to generate a regular expression to exactly match a numeric range or all addresses of a given CIDR block. COMMANDSalternation [options] [PATTERN...]Generate a regular expression that matches any of the
given patterns.
Options
Examples Match either lion, elephant, rhino, buffalo or leopard: $ rgxg alternation lion elephant rhino buffalo leopard (lion|elephant|rhino|buffalo|leopard) cidr [options] CIDR 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: $ 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]) Match 2001:db8:aaaa:bbbb:cccc:dddd::/96 limited to lower case letters: $ 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} escape [options] STRING Generate the regular expression which matches the given
string by escaping the escape characters.
Options
Examples Match '1+(2*(3-4))': $ rgxg escape 1+(2*(3-4)) 1\+\(2\*\(3-4\)\) help [COMMAND] Describe the usage of rgxg or the given COMMAND.
range [options] FIRST [LAST] 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: $ rgxg range 0 31 (3[01]|[12]?[0-9]) Match numbers from 0 to 31 with base 2: $ rgxg range -b 2 0 31 (1[01]{0,4}|0) Match 0 to 31 with base 16: $ rgxg range -b 16 0 31 1?[0-9A-Fa-f] Match 0 to 31 with base 16 limited to upper case letters: $ rgxg range -b 16 -U 0 31 1?[0-9A-F] Match 0 to 31 with base 16 limited to lower case letters: $ rgxg range -b 16 -l 0 31 1?[0-9a-f] Match 00 to 31: $ rgxg range -z 0 31 (3[01]|[0-2][0-9]) Match 0000 to 0031: $ rgxg range -z -m 4 0 31 (003[01]|00[0-2][0-9]) Match 0 to 31 and 00 to 31 and 000 to 031: $ rgxg range -Z -m 3 0 31 (0?3[01]|0?[0-2]?[0-9]) Match 0 to 31 and omit outer parentheses: $ rgxg range -N 0 31 3[01]|[12]?[0-9] Match all numbers greater than or equal to 4096: $ rgxg range 4096 ([1-9][0-9]{4,}|[5-9][0-9]{3}|4[1-9][0-9]{2}|409[6-9]) version Prints the version of the rgxg command.
EXIT STATUSThe exit status is 0 if the regular expression has been successfully generated. If an error occurred the exit status is 1.NOTESThe regular expressions generated by rgxg are supposed to be used in any context. This may lead to some side effects.For instance consider the following: $ echo '192.168.0.999' | grep -E "$(rgxg cidr 192.168.0.0/24)" 192.168.0.999 $ This is correct because the regular expression for '192.168.0.0/24' matches '192.168.0.99'. One can verify this by adding '-o' to grep: echo '192.168.0.999' | grep -oE "$(rgxg cidr 192.168.0.0/24)" 192.168.0.99 $ As rgxg cannot know in which context the generated regular expression is used, it is up to the user to ensure that the regular expression works as expected (e.g. by adding anchors like '^' and '$'). In the example above adding line anchors leads to the expected behaviour: $ echo '192.168.0.999' | grep -E "^$(rgxg cidr 192.168.0.0/24)$" $ SEE ALSOregex(7)AUTHORHannes von Haugwitz <hannes@vonhaugwitz.com>
Visit the GSP FreeBSD Man Page Interface. |