I have to parse strings that present name of files as:
myfilename.txt
anotherfilename.jpg
a.filename.with.dots.jpg
I need to extract the filename without it's extension. for example "myfilename.txt" should return "myfilename" and "a.filename.with.dots.jpg" should return "a.filename.with.dots" not that some filename are problematic in what they contain and the javascript should be able to handle this.
what's the best was of doing this? this is what I tried so far and didn't work.
namearr = name.split('.')
filename = namearr.splice()
I can use regex like
^(.?)..?$
for this but it seems like an overkill for this
the problem I see with other answered for this is that they don't take in account the number of dots the filename can contain. (not excluding the extension)