Skip to content

Commit 515fb5b

Browse files
authored
Merge pull request #1204 from pi-hole/tweak/regex_digit
Improve regex documentation
2 parents 522e07f + b9eff53 commit 515fb5b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

docs/regex/tutorial.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,24 @@ Example | Interpretation
8989

9090
In addition to character groups, there are also some special character classes available, such as
9191

92-
Character class | Group equivalent | Pi-hole specific | Interpretation
92+
Character class | Equivalent | Pi-hole specific | Interpretation
9393
--------------- | ---------------- | ---------------- | ---------------
94-
`[:digit:]` | `[0-9]` | No | matches digits
95-
`[:lower:]` | `[a-z]` | No | matched lowercase letters(FTL matches case-insensitive by default)
96-
`[:upper:]` | `[A-Z]` | No | matched uppercase letters(FTL matches case-insensitive by default)
97-
`[:alpha:]` | `[A-Za-z]` | No | matches alphabetic characters
98-
`[:alnum:]` | `[A-Za-z0-9]` | No | matches alphabetic characters and digits
99-
`[:blank:]` | `[ \t]` | Yes | blank characters
100-
`[:cntrl:]` | N/A | Yes | control characters
101-
`[:graph:]` | N/A | Yes | all printable characters except space
102-
`[:print:]` | N/A | Yes | printable characters including space
103-
`[:punct:]` | N/A | Yes | printable characters not space or alphanumeric
104-
`[:space:]` | `[ \f\n\r\t\v]` | Yes | white-space characters
105-
`[:xdigit:]` | `[0-9a-fA-F]` | Yes | hexadecimal digits
94+
`[[:digit:]]` | `[0-9]` | No | digits
95+
`[[:lower:]]` | `[a-z]` | No | lowercase letters*
96+
`[[:upper:]]` | `[A-Z]` | No | uppercase letters*
97+
`[[:alpha:]]` | `[A-Za-z]` | No | alphabetic characters*
98+
`[[:alnum:]]` | `[A-Za-z0-9]` | No | alphabetic characters* and digits
99+
`[[:blank:]]` | `[ \t]` | Yes | blank characters
100+
`[[:cntrl:]]` | N/A | Yes | control characters
101+
`[[:graph:]]` | N/A | Yes | all printable characters except space
102+
`[[:print:]]` | N/A | Yes | printable characters including space
103+
`[[:punct:]]` | N/A | Yes | printable characters not space or alphanumeric
104+
`[[:space:]]` | `[ \f\n\r\t\v]` | Yes | white-space characters
105+
`[[:xdigit:]]` | `[0-9a-fA-F]` | Yes | hexadecimal digits
106+
107+
*) FTL matches case-insensitive by default as case does not matter in domain names
108+
109+
Note that character classes are abbreviations, they need to be used in character groups, i.e., enclosed in `[]`. As such, the equivalent of `[0-9]` would be `[[:digit:]]`, *not* `[:digit:]`. It is allowed to mix character classes with classical character groups. For example, `[a-z0-9]` is identical to `[a-z[:digit:]]`.
106110

107111
# Advanced examples
108112

0 commit comments

Comments
 (0)