File extension is in extensions list: Difference between revisions
File extension is in extensions list (view source)
Revision as of 16:31, 10 November 2016
, 7 years ago→{{header|jq}}
Line 623:
"foo.C++" does not have an admissible file extension
"document.pdf" does not have an admissible file extension</lang>
=={{header|Objeck}}==
<lang objeck>
class FileExtension {
function : Main(args : String[]) ~ Nil {
files := ["MyData.a##", "MyData.tar.Gz", "MyData.gzip",
"MyData.7z.backup", "MyData...", "MyData", "MyData_v1.0.tar.bz2", "MyData_v1.0.bz2"];
exts := ["zip", "rar", "7z", "gz", "archive", "A##", "tar.bz2"];
each(i : files) {
HasExt(files[i], exts);
};
}
function : HasExt(file : String, exts : String[]) ~ Nil {
full_file := file->ToLower();
each(i : exts) {
full_ext := ".";
full_ext += exts[i]->ToLower();
if(full_file->EndsWith(full_ext)) {
IO.Console->Print(file)->Print(" has extension \"")->Print(exts[i])->PrintLine("\"");
return;
};
};
IO.Console->Print(file)->PrintLine(" does not have an extension in the list");
}
}</lang>
{{out}}
<pre>MyData.a## has extension "A##"
MyData.tar.Gz has extension "gz"
MyData.gzip does not have an extension in the list
MyData.7z.backup does not have an extension in the list
MyData... does not have an extension in the list
MyData does not have an extension in the list
MyData_v1.0.tar.bz2 has extension "tar.bz2"
MyData_v1.0.bz2 does not have an extension in the list</pre>
=={{header|PARI/GP}}==
|