Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript regex to detect CSV file type?

There seems to be a lot of questions asking for regex to detect a CSV file type, but none for javascript.

Given that a regular expression for images looks like /^image\/(gif|jpeg|png)$/, does anyone know what the same would look like for CSV?

Edit To be a little more clear, looking for both a "how-to" to regex check if file is a CSV and the common extensions associated. Thanks!

like image 837
crockpotveggies Avatar asked Dec 15 '22 22:12

crockpotveggies


1 Answers

The CSV file extension is typically .csv. So try matching against that:

.+(\.csv)$

like image 50
tskuzzy Avatar answered Feb 21 '23 10:02

tskuzzy