Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的正则表达式是:
var re = /^[a-z A-Z._]{1,15}$/;
我想允许这样做:('单引号)。
'
我怎样才能做到这一点?
例如,您可以使用以下正则表达式来允许类似的字符串abcd'dfgh:
abcd'dfgh
/^[A-Za-z\/\']+[A-Za-z]$/
要允许单引号,请将其添加到字符类中,例如^[a-z A-Z._']{1,15}$
^[a-z A-Z._']{1,15}$
此正则表达式允许'匹配'abc'_等a'b'c_。
'abc'_
a'b'c_