Generic regexps to build lenses
Author: Raphael Pinson raphink@gmail.com
| Rx | Generic regexps to build lenses |
| License | This file is licensed under the LGPL v2+, like the rest of Augeas. |
| Spaces | |
| space | A mandatory space or tab |
| opt_space | An optional space or tab |
| cl | A continued line with a backslash |
| cl_or_space | A cl or a space |
| cl_or_opt_space | A cl or a opt_space |
| General strings | |
| space_in | A string which not starting or ending with a space |
| no_spaces | A string with no spaces |
| word | An alphanumeric string |
| integer | One or more digits |
| relinteger | A relative integer |
| relinteger_noplus | A relative integer, without explicit plus sign |
| decimal | A decimal value (using ‘,’ or ‘.’ |
| reldecimal | A relative decimal |
| byte | |
| hex | A hex value |
| octal | An octal value |
| fspath | A filesystem path |
| All but... | |
| neg1 | Anything but a space, a comma or a comment sign |
| IPs | Cf. |
| ipv4 | |
| ipv6 | |
| ip | An ipv4 or ipv6 |
| hostname | A valid RFC 1123 hostname |
| device_name | A Linux device name like eth0 or i2c-0. |
| email_addr | To be refined |
| iso_8601 | ISO 8601 date time format |
let relinteger = /[-+]?[0-9]+/
A relative integer
let relinteger_noplus = /[-]?[0-9]+/
A relative integer, without explicit plus sign
let reldecimal = /[+-]?[0-9]+([.,][0-9]+)?/
A relative decimal
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}:)/
A mandatory space or tab
let space = /[ \t]+/
An optional space or tab
let opt_space = /[ \t]*/
A continued line with a backslash
let cl = /[ \t]*\\\\\n[ \t]*/
A cl or a space
let cl_or_space = cl | space
A cl or a opt_space
let cl_or_opt_space = cl | opt_space
A string which not starting or ending with a space
let space_in = /[^ \r\t\n].*[^ \r\t\n]|[^ \t\n\r]/
A string with no spaces
let no_spaces = /[^ \t\r\n]+/
An alphanumeric string
let word = /[A-Za-z0-9_.-]+/
One or more digits
let integer = /[0-9]+/
A relative integer
let relinteger = /[-+]?[0-9]+/
A relative integer, without explicit plus sign
let relinteger_noplus = /[-]?[0-9]+/
A decimal value (using ‘,’ or ‘.’
let decimal = /[0-9]+([.,][0-9]+)?/
A relative decimal
let reldecimal = /[+-]?[0-9]+([.,][0-9]+)?/
let byte = /25[0-5]?|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]/
A hex value
let hex = /0x[0-9a-fA-F]+/
An octal value
let octal = /0[0-7]+/
A filesystem path
let fspath = /[^ \t\n]+/
Anything but a space, a comma or a comment sign
let neg1 = /[^,# \n\t]+/
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}:)/
An ipv4 or ipv6
let ip = ipv4 | ipv6
A valid RFC 1123 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 Linux device name like eth0 or i2c-0.
let device_name = /[a-zA-Z0-9_?.+:!-]+/
To be refined
let email_addr = /[A-Za-z0-9_+.-]+@[A-Za-z0-9_.-]+/