I am trying to use JavaScript to convert this string
.txt|.pdf|.xls|.xlsx|.doc|.docx|.rtf|.jpg|.jpeg|.png|.gif
into this array
["txt", "pdf", "xls", "xlsx", "doc", "docx", "rtf", "jpg", "jpeg", "png", "gif"]
But it gives me this
[".txt", "pdf", "xls", "xlsx", "doc", "docx", "rtf", "jpg", "jpeg", "png", "gif"]
It holds a dot in front of the first element. What can I do since I don't know the regex? Here is my code:
let fileTypes = string.split('|.');
source
share