如何在文本框中允许特定的特殊字符,字母,数字? [英] How to allow particular special characters, letters, numbers in text box?

查看:98
本文介绍了如何在文本框中允许特定的特殊字符,字母,数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用正则表达式来避免文本框中的某些特殊字符。



我尝试过:



使用正则表达式,但如何允许特殊的特殊字符,字母,数字?

using regex for avoid some special characters in textbox.

What I have tried:

using regex for this one but how to allow particular special character,letters,numbers?

推荐答案

取决于您现有的正则表达式。

例如:

Depends on your existing Regex.
For example:
^\d+


仅允许数字。

Would allow only numbers.

^[-+]?\d+(\.\d+)?


允许带小数点的数字,以及可选的前导加号或减号。

要允许或禁止特定字符,我们需要知道您要允许的内容 - 但需要获取副本 Expresso [ ^ ] - 它是免费的,它会检查并生成正则表达式。

这将帮助您设计自己的符合您的规范需要。

Would allow numbers with a decimal point, and an optional leading plus or minus.
To allow or disallow specific characters, we'd need to know what you want to permit - but get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
It'll help you design your own to fit your specific needs.


这篇关于如何在文本框中允许特定的特殊字符,字母,数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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