我怎么能只允许字母和特殊字符用常规的前pression?
How can I allow only letters and special characters with a regular expression?
我建议你使用 GSkinner 的正则表达式构建器和试验了很多在右手侧上的例子。有许多变化得到这个工作做好。如果你想成为明确的,你可以使用:
I suggest you use GSkinner's REGEX builder and experiment with a lot of the examples on the right hand side. There are are many variations to get this job done. If you want to be explicit you can use:
/[a-zA-Z!@#$%¨&*()-=+/*.{}]/
托尼的回答也将正常工作,但要承担更多额外的字符比您在您的评论已经定义的值。
Tony's answer will also work, but includes more extra characters than the ones you've defined in your comment.