注册文件名 [英] Reg Ex for a File name

查看:103
本文介绍了注册文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

允许的角色



1. az

2. AZ

3. - (减去)

4.。(点)应该在字符串的中间,只有一次

5.(空格)



我在做什么是

^ [a-zA-Z0-9'-] + [\。]?[a-zA-Z0-9'-] + $



它起作用了。 JS错误 - 字符集中的范围无效



我甚至试图逃避减去相同的错误



^ [a-zA-Z0-9'\-] + [\。]?[a-zA-Z0-9'\-] + $



请帮助

Allowed characters

1. a-z
2. A-Z
3. -(minus)
4. .(dot) should come in the middle of the string and only once
5. (space)

What I am doing is
^[a-zA-Z0-9'- ]+[\.]?[a-zA-Z0-9'- ]+$

it dosent work. JS error - Invalid range in character set

I even tried escaping the minus still same error

^[a-zA-Z0-9'\- ]+[\.]?[a-zA-Z0-9'\- ]+$

please help

推荐答案





它的工作量。 JS错误 - 字符集中的范围无效



我甚至试图逃避减去相同的错误



^ [a-zA-Z0-9'\-] + [\。]?[a-zA-Z0-9'\-] +


it dosent work. JS error - Invalid range in character set

I even tried escaping the minus still same error

^[a-zA-Z0-9'\- ]+[\.]?[a-zA-Z0-9'\- ]+






请帮助


please help


你得到的错误是因为字符集中的文字短划线必须是第一个或最后一个。否则它被解释为表示范围:

^ [ - a-zA-Z0-9'] + [\。]?[ - a-zA-Z0- 9'] +
The error you are getting is because a literal dash in a character set must be first or last. Otherwise it is interpreted as indicating a range:
^[-a-zA-Z0-9' ]+[\.]?[-a-zA-Z0-9' ]+


这篇关于注册文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆