Replacing illegal character in fileName

后端 未结 7 1956
情书的邮戳
情书的邮戳 2020-12-24 10:39

In Java, I\'ve a File-Name-String. There I want to replace all illegal Characters with \'_\', but not a-z, 0-9, -,. and <

7条回答
  •  无人及你
    2020-12-24 11:13

    for NodeJS (v10), the function replaceAll() is undefined!

    The solution is:

    let newName = myString.replace(/[^a-zA-Z0-9.-]/gi, "_");
    

提交回复
热议问题