Jump to content

Extract file extension: Difference between revisions

(Added Kotlin)
Line 404:
 
=={{header|Forth}}==
 
{{update|Forth|The format of a suffix has been clarified, and the test-cases have been replaced with new ones.}}
 
<lang forth>: invalid? ( c -- f )
Line 428 ⟶ 426:
2dup type.quoted ." => " extension type.quoted cr ;
: tests
s" picturehttp://example.jpgcom/download.tar.gz" test
s" http://mywebsiteCharacterModel.com/picture/image.png3DS" test
s" myuniquefile.longextensiondesktop" test
s" IAmAFileWithoutExtensiondocument" test
s" /path/todocument.my/filetxt_backup" test
s" file/etc/pam.odd_oned/login" test ;</lang>
s" IDontHaveAnExtension." test ;</lang>
{{out}}
<pre>cr tests
'picturehttp://example.jpgcom/download.tar.gz' => '.jpggz'
'CharacterModel.3DS' => '.3DS'
'http://mywebsite.com/picture/image.png' => '.png'
'myuniquefile.longextensiondesktop' => '.longextensiondesktop'
'IAmAFileWithoutExtensiondocument' => ''
'/path/todocument.my/filetxt_backup' => ''
'file/etc/pam.odd_oned/login' => ''
'IDontHaveAnExtension.' => ''
ok</pre>
 
37

edits

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