只匹配字母和特殊字符与正则表达式 [英] Match only letters and special characters with RegExp

查看:161
本文介绍了只匹配字母和特殊字符与正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能只允许字母和特殊字符用常规的前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.

这篇关于只匹配字母和特殊字符与正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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