Help: Clarify documentation on regex character classes
In particular, give an example of matching `]`.
This commit is contained in:
parent
fcdc6e6173
commit
dc7a810a75
@ -136,15 +136,16 @@ The following characters have special meaning in regular expressions:
|
|||||||
or ``\\`` for a literal backslash ``\``. Escaping a non-special
|
or ``\\`` for a literal backslash ``\``. Escaping a non-special
|
||||||
character is unnecessary but allowed, e.g. ``\a`` matches ``a``.
|
character is unnecessary but allowed, e.g. ``\a`` matches ``a``.
|
||||||
``[ ]``
|
``[ ]``
|
||||||
Matches any character(s) inside the brackets
|
Matches any character(s) inside the brackets.
|
||||||
|
To match a literal ``]``, make it the first character, e.g., ``[]ab]``.
|
||||||
``[^ ]``
|
``[^ ]``
|
||||||
Matches any character(s) not inside the brackets
|
Matches any character(s) not inside the brackets.
|
||||||
|
To not match a literal ``]``, make it the first character, e.g., ``[^]ab]``.
|
||||||
``-``
|
``-``
|
||||||
Inside brackets, specifies an inclusive range between
|
Inside brackets, specifies an inclusive range between characters on
|
||||||
characters on either side e.g. ``[a-f]`` is ``[abcdef]``
|
either side, e.g., ``[a-f]`` is ``[abcdef]``.
|
||||||
To match a literal ``-`` using brackets, make it the first
|
To match a literal ``-`` using brackets, make it the first or the last
|
||||||
or the last character e.g. ``[+*/-]`` matches basic
|
character, e.g., ``[+*/-]`` matches basic mathematical operators.
|
||||||
mathematical operators.
|
|
||||||
``*``
|
``*``
|
||||||
Matches preceding pattern zero or more times
|
Matches preceding pattern zero or more times
|
||||||
``+``
|
``+``
|
||||||
|
Loading…
Reference in New Issue
Block a user