Rx

Generic regexps to build lenses

Author: Raphael Pinson rap.nosp@m.hink@gmai.nosp@m.l.com

Summary
RxGeneric regexps to build lenses
LicenseThis file is licensed under the LGPL v2+, like the rest of Augeas.
Spaces
spaceA mandatory space or tab
opt_spaceAn optional space or tab
clA continued line with a backslash
cl_or_spaceA cl or a space
cl_or_opt_spaceA cl or a opt_space
General strings
space_inA string which not starting or ending with a space
no_spacesA string with no spaces
wordAn alphanumeric string
integerOne or more digits
relintegerA relative integer
relinteger_noplusA relative integer, without explicit plus sign
decimalA decimal value (using ‘,’ or ‘.’
reldecimalA relative decimal
byte
hexA hex value
octalAn octal value
fspathA filesystem path
All but...
neg1Anything but a space, a comma or a comment sign
IPsCf.
ipv4
ipv6
ipAn ipv4 or ipv6
hostnameA valid RFC 1123 hostname
device_nameA Linux device name like eth0 or i2c-0.
email_addrTo be refined
iso_8601ISO 8601 date time format

License

This file is licensed under the LGPL v2+, like the rest of Augeas.

Spaces

space

let space = /[ \t]+/

A mandatory space or tab

opt_space

let opt_space = /[ \t]*/

An optional space or tab

cl

let cl = /[ \t]*\\\\\n[ \t]*/

A continued line with a backslash

cl_or_space

let cl_or_space = cl | space

A cl or a space

cl_or_opt_space

let cl_or_opt_space = cl | opt_space

A cl or a opt_space

General strings

space_in

let space_in = /[^ \r\t\n].*[^ \r\t\n]|[^ \t\n\r]/

A string which not starting or ending with a space

no_spaces

let no_spaces = /[^ \t\r\n]+/

A string with no spaces

word

let word = /[A-Za-z0-9_.-]+/

An alphanumeric string

integer

let integer = /[0-9]+/

One or more digits

relinteger

let relinteger = /[-+]?[0-9]+/

A relative integer

relinteger_noplus

let relinteger_noplus = /[-]?[0-9]+/

A relative integer, without explicit plus sign

decimal

let decimal = /[0-9]+([.,][0-9]+)?/

A decimal value (using ‘,’ or ‘.’ as a separator)

reldecimal

let reldecimal = /[+-]?[0-9]+([.,][0-9]+)?/

A relative decimal

byte

let byte = /25[0-5]?|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]/
A byte (0255)

hex

let hex = /0x[0-9a-fA-F]+/

A hex value

octal

let octal = /0[0-7]+/

An octal value

fspath

let fspath = /[^ \t\n]+/

A filesystem path

All but...

neg1

let neg1 = /[^,# \n\t]+/

Anything but a space, a comma or a comment sign

ipv4

let ipv4 = let dot = "." in byte . dot . byte . dot . byte . dot . byte

ipv6

let ipv6 = /(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})/ | ( /([0-9A-Fa-f]{1,4}:){6}/ . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/ . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/ ) | ( /([0-9A-Fa-f]{1,4}:){0,5}:/ . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/ . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/ ) | ( /::([0-9A-Fa-f]{1,4}:){0,5}/ . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/ . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/ ) | ( /[0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}/ . /[0-9A-Fa-f]{1,4}/ ) | /(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){1,7}:)/

ip

let ip = ipv4 | ipv6

An ipv4 or ipv6

hostname

let hostname = /(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*( [A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/

A valid RFC 1123 hostname

device_name

let device_name = /[a-zA-Z0-9_?.+:!-]+/

A Linux device name like eth0 or i2c-0.  Might still be too restrictive

email_addr

let email_addr = /[A-Za-z0-9_+.-]+@[A-Za-z0-9_.-]+/

To be refined

iso_8601

ISO 8601 date time format

let space = /[ \t]+/
A mandatory space or tab
let opt_space = /[ \t]*/
An optional space or tab
let cl = /[ \t]*\\\\\n[ \t]*/
A continued line with a backslash
let cl_or_space = cl | space
A cl or a space
let cl_or_opt_space = cl | opt_space
A cl or a opt_space
let space_in = /[^ \r\t\n].*[^ \r\t\n]|[^ \t\n\r]/
A string which not starting or ending with a space
let no_spaces = /[^ \t\r\n]+/
A string with no spaces
let word = /[A-Za-z0-9_.-]+/
An alphanumeric string
let integer = /[0-9]+/
One or more digits
let relinteger = /[-+]?[0-9]+/
A relative integer
let relinteger_noplus = /[-]?[0-9]+/
A relative integer, without explicit plus sign
let decimal = /[0-9]+([.,][0-9]+)?/
A decimal value (using ‘,’ or ‘.’
let reldecimal = /[+-]?[0-9]+([.,][0-9]+)?/
A relative decimal
let byte = /25[0-5]?|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]/
let hex = /0x[0-9a-fA-F]+/
A hex value
let octal = /0[0-7]+/
An octal value
let fspath = /[^ \t\n]+/
A filesystem path
let neg1 = /[^,# \n\t]+/
Anything but a space, a comma or a comment sign
let ipv4 = let dot = "." in byte . dot . byte . dot . byte . dot . byte
let ipv6 = /(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})/ | ( /([0-9A-Fa-f]{1,4}:){6}/ . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/ . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/ ) | ( /([0-9A-Fa-f]{1,4}:){0,5}:/ . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/ . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/ ) | ( /::([0-9A-Fa-f]{1,4}:){0,5}/ . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/ . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/ ) | ( /[0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}/ . /[0-9A-Fa-f]{1,4}/ ) | /(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})/ | /(([0-9A-Fa-f]{1,4}:){1,7}:)/
let ip = ipv4 | ipv6
An ipv4 or ipv6
let hostname = /(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*( [A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/
A valid RFC 1123 hostname
let device_name = /[a-zA-Z0-9_?.+:!-]+/
A Linux device name like eth0 or i2c-0.
let email_addr = /[A-Za-z0-9_+.-]+@[A-Za-z0-9_.-]+/
To be refined
Close