REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 3-Aug-2010 Edit History |
Return the file suffix of a filename or url. Else, NONE.
Arguments:
path [file! url! string!]
See also:
The SUFFIX? function can be used to obtain the file extention (e.g. .exe, .txt, .jpg, etc.) that is part of a filename.
print suffix? %document.txt
.txt
print suffix? %program.exe
.exe
print suffix? %dir/path/doc.txt
.txt
print suffix? %file.type.r
.r
print suffix? http://www.rebol.com/doc.txt
.txt
If there is no suffix, a NONE is returned:
print suffix? %filename
none
The suffix function can be used with any string datatype, but always returns a FILE! datatype if the suffix was found.
print type? suffix? %file.txt
file!
print type? suffix? "file.txt"
file!
print type? suffix? http://www.rebol.com/file.txt
file!
This was done to allow code such as:
url: http://www.rebol.com/docs.html
if find [%.txt %.html %.htm %.doc] suffix? url [
print [url "is a document file."]
]
http://www.rebol.com/docs.html is a document file.
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |