Extract file extension: Difference between revisions
Content added Content deleted
(→{{header|Forth}}: Add Fortran.) |
(→Task: improve formatting and wording) |
||
Line 1: | Line 1: | ||
{{draft task}} |
{{draft task}} |
||
{{task heading}} |
|||
Write a program that takes one string argument representing the path to a file and returns the file's extension, or the null string if the file path has no extension. |
|||
Write a function or program that |
|||
⚫ | |||
* takes one string argument representing the path/URL to a file |
|||
* returns the file's extension, or an empty string if it has no extension. |
|||
{{task heading|Details}} |
|||
Show here the action of your routine on the following examples: |
|||
⚫ | |||
# picture.jpg returns .jpg |
|||
* The file name is separated from preceding directory parts, if any, by a forward slash. |
|||
⚫ | |||
⚫ | |||
{{task heading|Test cases}} |
|||
⚫ | |||
⚫ | |||
{| class="wikitable" |
|||
⚫ | |||
|- |
|||
<br><br> |
|||
! Input |
|||
! Output |
|||
! Comment |
|||
|- |
|||
| <code>picture.jpg</code> |
|||
| <code>.jpg</code> |
|||
| |
|||
|- |
|||
⚫ | |||
| <code>.png</code> |
|||
| |
|||
|- |
|||
⚫ | |||
| <code>.longextension</code> |
|||
| |
|||
|- |
|||
⚫ | |||
| <code></code> |
|||
| ''empty string'' |
|||
|- |
|||
| <code>/path/to.my/file</code> |
|||
| <code></code> |
|||
⚫ | |||
|- |
|||
| <code>file.odd_one</code> |
|||
| <code></code> |
|||
⚫ | |||
|} |
|||
<hr> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |