使用连字符和数字的正则表达式 [英] Regular expression using hypens and digits
本文介绍了使用连字符和数字的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以这样的方式创建正则表达式:必须在条件为的文本框中仅允许输入连字符和数字
I want to create a regular expression in such a way that only hypens and digits must be allowed in the text box the criteria is
- Hypen不应排在首位和最后一位
- Hypen的两端必须有数字
- 文本框中可以有n个连字符和数字
预先感谢
推荐答案
我简直不敢相信,我通过用正则表达式进行猜测得到了它,希望它能正常工作.
I can't believe it, I got it by giving a guess in regular expression i hope this will work fine.
(\d+(\d*\\-\d+)+\d*)|\d+
这篇关于使用连字符和数字的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文