Upload Tizen:Main source
[external/augeas.git] / lenses / rx.aug
1 (*
2 Module: Rx
3    Generic regexps to build lenses
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: License
8   This file is licensed under the LGPLv2+, like the rest of Augeas.
9 *)
10
11
12 module Rx =
13
14 (* Spaces *)
15 let space     = /[ \t]+/
16 let opt_space = /[ \t]*/
17 let space_in  = /[^ \t\n].*[^ \t\n]|[^ \t\n]/
18 let no_spaces = /[^ \t\n]+/
19
20 (* Generic fields *)
21 let word      = /[A-Za-z0-9_.-]+/
22 let integer   = /[0-9]+/
23 let decimal   = /[0-9]+([.,][0-9]+)?/
24
25 (* A filesystem path *)
26 let fspath    = /[^ \t\n]+/
27
28 (* All but... *)
29 (* Anything but a space, a comma or a comment sign *)
30 let neg1      = /[^,# \n\t]+/
31
32
33 (*
34  * IPs
35  * Cf. http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6/ (in fr)
36  *)
37 let ipv4 =
38   let dot     = "." in
39   let digits  = /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/ in
40     digits . dot . digits . dot . digits . dot . digits
41
42 let ipv6 =
43   /(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})/
44   | /(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})/
45   | /(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})/
46   | /(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})/
47   | /(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})/
48   | /(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})/
49   | (    /([0-9A-Fa-f]{1,4}:){6}/
50            . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/
51            . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/
52     )
53   | (    /([0-9A-Fa-f]{1,4}:){0,5}:/
54            . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/
55            . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/
56     )
57   | (    /::([0-9A-Fa-f]{1,4}:){0,5}/
58            . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/
59            . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/
60     )
61   | (    /[0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}/
62            . /[0-9A-Fa-f]{1,4}/
63     )
64   | /(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})/
65   | /(([0-9A-Fa-f]{1,4}:){1,7}:)/
66
67 let ip        = ipv4 | ipv6
68
69 (*
70  * A Linux device name like eth0 or i2c-0. Might still be too restrictive
71  *)
72
73 let device_name = /[a-zA-Z0-9_?.+:!-]+/
74
75 (*
76  * Variable: email_addr
77  *    To be refined
78  *)
79 let email_addr = /[A-Za-z0-9_\+\.-]+@[A-Za-z0-9_\.-]+/
80