Jump to content

Extract file extension: Difference between revisions

Added AutoHotkey
(initial submission of php 7.x solution to this problem)
(Added AutoHotkey)
Line 402:
{{output}}
<pre>{{"http://example.com/download.tar.gz", ".gz"}, {"CharacterModel.3DS", ".3DS"}, {".desktop", ".desktop"}, {"document", ""}, {"document.txt_backup", ""}, {"/etc/pam.d/login", ""}}</pre>
 
=={{header|AutoHotkey}}==
<lang AutoHotkey>data := ["http://example.com/download.tar.gz"
,"CharacterModel.3DS"
,".desktop"
,"document"
,"document.txt_backup"
,"/etc/pam.d/login"]
 
for i, file in data{
RegExMatch(file, "`am)\.\K[a-zA-Z0-9]+$", ext)
result .= file " --> " ext "`n"
}
MsgBox % result</lang>
{{out}}
<pre>http://example.com/download.tar.gz --> gz
CharacterModel.3DS --> 3DS
.desktop --> desktop
document -->
document.txt_backup -->
/etc/pam.d/login --> </pre>
 
=={{header|AWK}}==
299

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.