Filenames
---------
`(require 'filename)' or `(require 'glob)'
- Function: filename:match?? pattern
- Function: filename:match-ci?? pattern
Returns a predicate which returns a non-false value if its string
argument matches (the string) PATTERN, false otherwise. Filename
matching is like "glob" expansion described the bash manpage,
except that names beginning with `.' are matched and `/'
characters are not treated specially.
These functions interpret the following characters specially in
PATTERN strings:
`*'
Matches any string, including the null string.
`?'
Matches any single character.
`[...]'
Matches any one of the enclosed characters. A pair of
characters separated by a minus sign (-) denotes a range; any
character lexically between those two characters, inclusive,
is matched. If the first character following the `[' is a
`!' or a `^' then any character not enclosed is matched. A
`-' or `]' may be matched by including it as the first or
last character in the set.
- Function: filename:substitute?? pattern template
- Function: filename:substitute-ci?? pattern template
Returns a function transforming a single string argument according
to glob patterns PATTERN and TEMPLATE. PATTERN and TEMPLATE must
have the same number of wildcard specifications, which need not be
identical. PATTERN and TEMPLATE may have a different number of
literal sections. If an argument to the function matches PATTERN
in the sense of `filename:match??' then it returns a copy of
TEMPLATE in which each wildcard specification is replaced by the
part of the argument matched by the corresponding wildcard
specification in PATTERN. A `*' wildcard matches the longest
leftmost string possible. If the argument does not match PATTERN
then false is returned.
TEMPLATE may be a function accepting the same number of string
arguments as there are wildcard specifications in PATTERN. In the
case of a match the result of applying TEMPLATE to a list of the
substrings matched by wildcard specifications will be returned,
otherwise TEMPLATE will not be called and `#f' will be returned.
((filename:substitute?? "scm_[0-9]*.html" "scm5c4_??.htm")
"scm_10.html")
=> "scm5c4_10.htm"
((filename:substitute?? "??" "beg?mid?end") "AZ")
=> "begAmidZend"
((filename:substitute?? "*na*" "?NA?") "banana")
=> "banaNA"
((filename:substitute?? "?*?" (lambda (s1 s2 s3) (string-append s3 s1))) "ABZ")
=> "ZA"
- Function: replace-suffix str old new
STR can be a string or a list of strings. Returns a new string
(or strings) similar to `str' but with the suffix string OLD
removed and the suffix string NEW appended. If the end of STR
does not match OLD, an error is signaled.
(replace-suffix "/usr/local/lib/slib/batch.scm" ".scm" ".c")
=> "/usr/local/lib/slib/batch.c"