Get the File Name

Published by Nomore in

Create a function that returns the selected filename from a path. Include the extension in your answer.

Examples

GetFilename("C:/Projects/pil_tests/ascii/edabit.txt") ➞ "edabit.txt"

GetFilename("C:/Users/johnsmith/Music/Beethoven_5.mp3") ➞ "Beethoven_5.mp3"

GetFilename("ffprobe.exe") ➞ "ffprobe.exe"

Notes

  • Tests will include both absolute and relative paths.
  • For simplicity, all paths will include forward slashes.
Watch a quick demo on how Edabit works.