更新时间:2022-11-14 21:21:23
大功告成.试试这个:
/^[a-zA-Z0-9 .!?"-]+$/
请注意,-
字符的位置很重要.如果它出现在两个字符之间(例如 a-z
),则表示一个字符范围.如果它出现在字符类的开头或结尾(或者如果它被转义),它代表一个文字连字符.
Note that the position of the -
character is important. If it appears between two characters (e.g. a-z
) it represents a character range. If it appears in at the beginning or end of the character class (or if it's escaped) it represents a literal hyphen character.