techiall / Blog

🍋 [My Blog] See discussions
https://github.com/techiall/Blog/discussions
MIT License
8 stars 1 forks source link

Regex | windows文件名不能包含的字符 #32

Open techiall opened 5 years ago

techiall commented 5 years ago

Python 版本

import re

def new_name(file_name):
       return re.sub(r"[\/\\\:\*\?\"\<\>\|]", "-", file_name)

JavaScript 版本

function new_name(file_name) {
    return file_name.replace(/[\|\/\\\:\?\"\<\>]/mg, "-");
}