Jump to content

Extract file extension: Difference between revisions

Add ed example
(Add ed example)
 
Line 952:
.
</syntaxhighlight>
 
=={{header|Ed}}==
 
Prints empty line for extension-less/extension-invalid names.
 
<syntaxhighlight>
H
,p
g/.*/s/^.*(\.[[:alnum:]]+)$/\1/g
v/^\.[[:alnum:]]+$/s/.*//
,p
Q
</syntaxhighlight>
 
{{out}}
 
<pre>$ cat extension.ed | ed -E extension.input
Newline appended
109
http://example.com/download.tar.gz
CharacterModel.3DS
.desktop
document
document.txt_backup
/etc/pam.d/login
.gz
.3DS
.desktop
 
 
 
?
Warning: buffer modified</pre>
 
=={{header|Emacs Lisp}}==
46

edits

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