Regular expression for valid filename

后端 未结 10 1642
被撕碎了的回忆
被撕碎了的回忆 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:49

    This is a minor change to Engineers answer.

    string regex = @"^[\w\- ]+[\w\-. ]*$"
    

    This will block ".txt" which isn't valid.

    Trouble is, it does block "..txt" which is valid

提交回复
热议问题