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^!\[\]{}@$%+=]+$
.