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 LGPLv2+, like the rest of Augeas.
Spaces
spaceA mandatory space or tab
opt_spaceAn optional space or tab
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
integerA relative integer
decimalA decimal value (using ‘,’ or ‘.’
fspathA filesystem path
All but...
neg1Anything but a space, a comma or a comment sign
IPsCf.
ipv4
ipv6
ipAn ipv4 or ipv6
device_nameA Linux device name like eth0 or i2c-0.
email_addrTo be refined

License

This file is licensed under the LGPLv2+, 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

General strings

space_in

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

A string which not starting or ending with a space

no_spaces

let no_spaces = /[^ \t\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

integer

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

A relative integer

decimal

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

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

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 let digits = /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/ in digits . dot . digits . dot . digits . dot . digits

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

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

let space = /[ \t]+/
A mandatory space or tab
let opt_space = /[ \t]*/
An optional space or tab
let space_in = /[^ \t\n].*[^ \t\n]|[^ \t\n]/
A string which not starting or ending with a space
let no_spaces = /[^ \t\n]+/
A string with no spaces
let word = /[A-Za-z0-9_.-]+/
An alphanumeric string
let integer = /[0-9]+/
One or more digits
let decimal = /[0-9]+([.,][0-9]+)?/
A decimal value (using ‘,’ or ‘.’
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 let digits = /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/ in digits . dot . digits . dot . digits . dot . digits
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 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