Regular expression for valid filename

后端 未结 10 1641
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 18:11

I already gone through some question in StackOverflow regarding this but nothing helped much in my case.

I want to restrict the user to provide a filename that shoul

10条回答
  •  渐次进展
    2020-12-29 18:55

    For full character set (Unicode) use ^[\p{L}0-9_\-.~]+$

    or perhaps ^[\p{L}\p{N}_\-.~]+$ would be more accurate if we are talking about Unicode.

    I added a '~' simply because I have some files using that character.

提交回复
热议问题