Consider the following filename:
hls_a128_v4.m3u8
We are interested in getting filename only (without extension). We can do so with the help of following code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://hashaam.com/2017/09/02/get-filename-without-extension | |
let path = "hls_a128_v4.m3u8" | |
let url = URL(string: path) | |
let filename = url?.deletingPathExtension().lastPathComponent | |
print(filename) // hls_a128_v4 | |
let fileExtension = url?.pathExtension | |
print(fileExtension) // m3u8 |
I do consider all the ideas you’ve presented to your post. They’re really convincing and can definitely work. Nonetheless, the posts are too brief for newbies. Could you please prolong them a little from next time? Thank you for the post.
LikeLike
Noted. Will come back with new posts and put them in proper guide format.
LikeLike