Extract file extension: Difference between revisions
m
→{{header|Sidef}}: updated the code to match the current specification of the task
(→{{header|Fortran}}: Happily, no change is needed beyond adding the new trials.) |
m (→{{header|Sidef}}: updated the code to match the current specification of the task) |
||
Line 1,084:
=={{header|Sidef}}==
filename.match(/(\.[a-z0-9]+)\z/i).to_s
}▼
var files = [
'http://example.com/download.tar.gz',
'CharacterModel.3DS',
▲<lang ruby>func extension (filename) {
'.desktop',
'document',
'document.txt_backup',
'/etc/pam.d/login',
]
▲}
files.each {|f|
printf("%-36s -> %-11s\n", f.dump, extension(f).dump)
}</lang>
{{out}}
<pre>
"CharacterModel.3DS" -> ".3DS"
".desktop" -> ".desktop"
"document" -> ""
"document.txt_backup" -> ""
"/etc/pam.d/login" -> ""
</pre>
|