Extract file extension: Difference between revisions

Content added Content deleted
m (→‎Task: clarify)
(→‎Task: Replace the test-cases with more realistic ones (that also catch more edge cases). This doesn't change the task requirements.)
Line 27: Line 27:
! Comment
! Comment
|-
|-
| <code>picture.jpg</code>
| <code>image.jpg</code>
| <code>.jpg</code>
| <code>.jpg</code>
|
|
|-
|-
| <code><nowiki>http://mywebsite.com/picture/image.png</nowiki></code>
| <code><nowiki>http://example.com/download.tar.gz</nowiki></code>
| <code>.png</code>
| <code>.gz</code>
|
|
|-
|-
| <code>myuniquefile.longextension</code>
| <code>.desktop</code>
| <code>.longextension</code>
| <code>.desktop</code>
|
|
|-
|-
| <code>IAmAFileWithoutExtension</code>
| <code>document</code>
| <code></code>
| <code></code>
| ''empty string''
| ''empty string''
|-
|-
| <code>/path/to.my/file</code>
| <code>document.txt_backup</code>
| <code></code>
| <code></code>
| ''empty string, as the period is in the directory name rather than the file name''
| ''empty string, because <code>_</code> is not a letter or number''
|-
|-
| <code>file.odd_one</code>
| <code>/etc/pam.d/login</code>
| <code></code>
| <code></code>
| ''empty string, because <code>_</code> is not a letter or number''
| ''empty string, as the period is in the parent directory name rather than the filename''
|}
|}