如何验证文本框只能输入从0到24逗号分隔的数字。 [英] How to validate textbox to enter only number from 0 to 24 comma separated.

查看:98
本文介绍了如何验证文本框只能输入从0到24逗号分隔的数字。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要一个正则表达式来验证文本框只能输入1到24之间用逗号分隔的数字。请帮帮我。

Hi
I need a regular expression to validate a textbox to enter only numbers from 1 to 24 with comma separated. Please help me.

推荐答案

([1-9] | 1 [0 -9] | 2 [0-4])(,([1-9] | 1 [0-9] | 2 [0-4]))* [ ^ ]

将其分解......



[1-9] | 1 [0-9] | 2 [0-4] 此块表示1到24之间的数值范围...考虑到正则表达式正在处理文本,带有字符,对数字一无所知,所以你必须创建一个像数字过滤器一样的字符映射...

第二部分实际上是相同的,但有一个在逗号之前分隔数字......
([1-9]|1[0-9]|2[0-4])(,([1-9]|1[0-9]|2[0-4]))*[^]
To break it down...

[1-9]|1[0-9]|2[0-4] This block is representing a numeric range from 1 to 24...Consider that regex is working with text, with character and know nothing of numbers, so you have to create character map that behaves like a numeric filter...
The second part is actually the same, but there is a preceding comma to separate the numbers...


这篇关于如何验证文本框只能输入从0到24逗号分隔的数字。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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