|
|
Line 1,174: |
Line 1,174: |
|
</pre> |
|
</pre> |
|
|
|
|
⚫ |
=={{header| FreePascal}}== |
|
⚫ |
<syntaxhighlight lang="pascal"> Program Extract_file_extension; |
|
|
|
|
⚫ |
{FreePascal has the built-in function ExtractFileExt which returns the file extension. |
|
⚫ |
* it does need charachters before the period to return the proper extension and it returns |
|
⚫ |
* the extension including the period} |
|
|
|
|
⚫ |
|
|
|
|
|
⚫ |
Const arr : array of string = ('http://example.com/download.tar.gz','CharacterModel.3DS','.desktop', |
|
⚫ |
'document','document.txt_backup','/etc/pam.d/login'); |
|
|
|
|
⚫ |
Function extractextension(fn: String): string; |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
fn := 'prefix' + fn; {add charachters before the period} |
|
⚫ |
fn := ExtractFileExt(fn); |
|
⚫ |
For i := 2 to length(fn) Do {skip the period} |
|
⚫ |
If Not IsLetterOrDigit(fn[i]) Then exit(''); |
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
writeln(i:35,' -> ',extractextension(i)) |
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
http://example.com/download.tar.gz -> gz |
|
⚫ |
CharacterModel.3DS -> 3DS |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
|
|
=={{header|Frink}}== |
|
=={{header|Frink}}== |
Line 2,003: |
Line 1,964: |
|
null ok |
|
null ok |
|
></pre> |
|
></pre> |
|
⚫ |
|
|
|
==={{header|Free Pascal}}=== |
|
⚫ |
<syntaxhighlight lang="pascal"> |
|
|
Program Extract_file_extension; |
|
|
|
|
⚫ |
{FreePascal has the built-in function ExtractFileExt which returns the file extension. |
|
⚫ |
* it does need charachters before the period to return the proper extension and it returns |
|
⚫ |
* the extension including the period} |
|
|
|
|
⚫ |
|
|
|
|
|
⚫ |
Const arr : array of string = ('http://example.com/download.tar.gz','CharacterModel.3DS','.desktop', |
|
⚫ |
'document','document.txt_backup','/etc/pam.d/login'); |
|
|
|
|
⚫ |
Function extractextension(fn: String): string; |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
fn := 'prefix' + fn; {add charachters before the period} |
|
⚫ |
fn := ExtractFileExt(fn); |
|
⚫ |
For i := 2 to length(fn) Do {skip the period} |
|
⚫ |
If Not IsLetterOrDigit(fn[i]) Then exit(''); |
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
writeln(i:35,' -> ',extractextension(i)) |
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
http://example.com/download.tar.gz -> gz |
|
⚫ |
CharacterModel.3DS -> 3DS |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
|
=={{header|Perl}}== |
|
=={{header|Perl}}== |