admin管理员组

文章数量:1345086

I want to rename file name to the expected output. The problem is some user has upload file name with special characters that I cant put on replace statement. If using replace(/\W/g, '') it will remove extension "."

My requirement is :

  1. replace space into "_"
  2. only allow alphanumeric characters, remove all special characters include "."
  3. maintain file .extension

Example :

var file_name = "6$.6j& Fh*^h�

本文标签: javascriptRemove not alphanumeric characters from string without extensionStack Overflow