10
5
Your challenge is to find the file extension of a provided filename:
hi.txt -> txt or .txt
carrot.meme -> meme or .meme
lol (undefined behavior)
what..is..this..file -> file or .file
.bashrc -> bashrc or .bashrc
T00M@n3KaPZ.h0wC[]h -> h0wC[]h or .h0wC[]h
agent.000 -> 000 or .000
You must get the text from the last . or after the last . to the end of the string. The first capturing group match of the regular expression /\.([^.]+)$/ works, and so does splitting the input on .s and returning the last one.
The file name will always contain at least one ., but it may contain multiple .. (see examples)
The input will always match ^[.a-zA-Z0-9^!\[\]{}@$%+=]+$.
17
Please consider using the Sandbox in the future to get feedback on your challenges before posting them to the main site.
– Mego – 2017-05-16T20:45:43.2101https://codegolf.meta.stackexchange.com/a/12432/59376 - Got this idea from your challenge. – Magic Octopus Urn – 2017-05-16T21:51:19.607
@carusocomputing nice challenge! – programmer5000 – 2017-05-17T00:06:53.463
1why the negative votes? Is this challenge "exceedingly trivial" or so ? – Abel Tom – 2017-05-17T05:09:40.793
@AbelTom edit history would suggest downvotes were for the lack of specifications in the first draft of this question. – Patrick Roberts – 2017-05-17T05:12:29.793
@Arjun the downvote count seems to be slowly increasing. I have no idea why. – programmer5000 – 2017-05-18T11:22:31.483