Extract file extension: Difference between revisions

Content added Content deleted
(Added 11l)
Line 53: Line 53:


<hr>
<hr>

=={{header|11l}}==

{{trans|Python}}
<lang 11l>F extract_ext(path)
V m = re:‘\.[A-Za-z0-9]+$’.search(path)
R I m {m.group(0)} E ‘’

V paths = [‘http://example.com/download.tar.gz’,
‘CharacterModel.3DS’,
‘.desktop’,
‘document’,
‘document.txt_backup’,
‘/etc/pam.d/login’]

L(path) paths
print(path.rjust(max(paths.map(p -> p.len)))‘ -> ’extract_ext(path))</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|ALGOL 68}}==
=={{header|ALGOL 68}}==