Method glob()
- Method
glob
bool
glob(string
glob
,string
str
)
zero
|string
glob(array
(string
)glob
,string
str
)
array
(string
) glob(string
glob
,array
(string
)str
)
array
(string
) glob(array
(string
)glob
,array
(string
)str
)- Description
Match strings against a glob pattern.
- Parameter
glob
string
The glob pattern.
Some characters have special meanings.
When a character range is not started the following characters have special meanings:
'?'
A question sign (
'?'
) matches any character.'*'
An asterisk (
'*'
) matches a string of arbitrary length.'\\'
A back-slash (
'\\'
) escapes the following character so that it is matched verbatim.'['
A left-bracket (
'['
) starts a character range.If a character range is started the following characters have special meanings:
'\\'
Escape (as above).
']'
A right-bracket (
']'
) ends a character range.'^'
The characters
'^'
and'!'
invert the character range if they are the first character in the range and otherwise match themselves.'!'
'-'
The character
'-'
separates the first and last characters in a character sequence.All other characters only match themselves.
array
(string
)An array of glob patterns (as above).
The function returns the matching glob if any of the given patterns match. Otherwise
0
. If the second argument (str
) is an array it will behave as if the first argument is a string (see below).- Parameter
str
string
1
is returned if the stringstr
matchesglob
,0
(zero) otherwise.array
(string
)All strings in the array
str
are matched againstglob
, and those that match are returned in an array (in the same order).- Note
In Pike 8.0 and earlier only
'?'
and'*'
had special meanings. The old implementation is available as 8.0::glob().- Note
In Pike 8.0 and earlier
1
was also returned when matching an array of globs against a single string.- See also