【发布时间】:2021-06-02 23:01:42
【问题描述】:
我正在使用正则表达式模式匹配添加对字符串的限制,但它不起作用,因为我在正则表达式方面没有太多经验。 就像不可能没有(没有)或[没有]。
abc.(% -->false
abc.)% -->false
abc.(%] -->false
abc.)%] -->false
1abc9.(%[ -->false
abc.)%[ -->false
abc.(%( -->false
abc.)%) -->false
19.(%)% -->true
19.[%]% -->true
2009% --> true
19.1245 -- true
10.[5-9]% -- true
/^[^\s\[\]^$.|A-Z]*(?:(?:\[[^\s\[\]\\]+](?!\])|%[^\r\n\?\$\*\.\[\+\(\)\]\.\^%]+%(?=\||$)|\|[^\s\[\]^A-Z\\]+)[^\s\[\]^$.|?*+()A-Z\\]*)*$/
The string is fine if it have start with ( and end with )
19[1-3] is fine
2014.56(core) is fine
【问题讨论】:
标签: javascript regex regexp-replace