Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
拡張子が .csv および .txt のファイルのみをアップロードしたいのですが、大文字と小文字は区別されません。
たとえば、.csv、.CSV、.CsV、.txt、.tXt、.TxT ...
私は現在これを使用しています
(?i)[.](csv|txt)
ただし、拡張子が大文字と小文字を区別する場合は機能しません。
この正規表現は、クライアント側とサーバー側の両方の検証に役立ちます。
^.*\.([cC][sS][vV]|[tT][xX][tT]??)$
名前として少なくとも 1 文字 (.txt または .csv の前) が必要な場合は、次の方法が役立ちます。
^.+\.([cC][sS][vV]|[tT][xX][tT]??)$
次のように、(?-i) で終了する必要があります。
(?i)[.](csv|txt)(?-i)