SSH2 Manpage for sshregex
Description
This document describes the regular expressions (or globbing patterns) used in filename globbing with scp2 and sftp2.
Patterns
The escape character is a backslash "\". With this you can escape meta characters which you'd like to use in their plain character form.In the following examples literal "E" and "F" denote any expression, be it a pattern or character, etc.
- *
- Match any string consisting of zero or more characters. The characters can be any characters apart from slashes ( / ). However, the asterisk does not match a string if the string contains a dot (.) as its first character, or if the string contains a dot immediately after a slash. This means that the asterisk cannot be used to match filenames that have a dot as their first character.If the previous character is a slash ( / ), or the asterisk (*) is used to denote a match at the beginning of a string, it does match a dot (.).That is, the "*" functions as is normal in UNIX shell fileglobs.
- ?
- Match any single character except for a slash ( / ). However, do not match a dot (.) if located at the beginning of the string, or if the previous character is a slash ( / ).That is, "?" functions as is normal in Unix shell fileglobs (at least ZSH, although discarding the dot may not be a standard procedure).
- **/
- Match any sequence of characters that is either empty, or ends in a slash. However, the substring "/." is not allowed. This mimics ZSH's ingenious **/ construct. (Observe that "**" is equivalent to "*".)
- E#
- Act as Kleene star, match E zero or more times.
- E##
- Closure, match E one or more times.
- (
- Start a capturing subexpression.
- )
- End a capturing subexpression.
- E|F
- Disjunction, match (inclusively) either E or F. E is preferred if both match.
- [
- Start a character set. (See below).
Character Sets
A character set starts with "[" and ends at nonescaped "]" that is not part of a POSIX character set specifier and that does not follow immediately after "[".The following characters have a special meaning and need to be escaped if meant literally:
- - (minus sign)
- A range operator, except immediately after "[", where it loses its special meaning.
- ^ or !
- If immediately after the starting "[", denotes a complement: the whole character set will be complemented. Otherwise literal. "^".
- [:alnum:]
- Characters for which "isalnum" returns
true
(see ctype.h).
- [:alpha:]
- Characters for which "isalpha" returns
true
(see ctype.h).
- [:cntrl:]
- Characters for which "iscntrl" returns
true
(see ctype.h).
- [:digit:]
- Characters for which "isdigit" returns
true
(see ctype.h).
- [:graph:]
- Characters for which "isgraph" returns
true
(see ctype.h).
- [:lower:]
- Characters for which "islower" returns
true
(see ctype.h).
- [:print:]
- Characters for which "isprint" returns
true
(see ctype.h).
- [:punct:]
- Characters for which "ispunct" returns
true
(see ctype.h).
- [:space:]
- Characters for which "isspace" returns
true
(see ctype.h).
- [:upper:]
- Characters for which "isupper" returns
true
(see ctype.h).
- [:xdigit:]
- Characters for which "isxdigit" returns
true
(see ctype.h).
Example
[[:xdigit:]XY] is typically equivalent to [0123456789ABCDEFabcdefXY] .
Authors
SSH Communications Security Corp.For more information, see http://www.ssh.com/.
See also
scp2 (1), sftp2 (1)