本文介绍了普通EX pression问题时,验证“/”字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直有一些问题经常EX pressions。我想验证用户输入时,公交车号码输入。

I have been having some problems with regular expressions. I want to validate user input when a bus number is entered.

例如:37,37A,37S,37A / L,16A / 250,16A / 250K等

Examples: 37, 37A, 37S, 37A/L, 16A/250, 16A/250K etc

常规EX pression我想出了为

The regular expression I came up with is

(^\d{1,3}[A-Z]{0,3})|(^[\d{1,3}[A-Z]{0,3}\/\d{0,3}[A-Z]{0,3}])

据验证37,37A,37S但是当涉及到​​验证37A / L失败。谁能告诉我在哪里,我错了这个?

It validates 37, 37A, 37S but when it comes to validating 37A/L it fails. Can someone tell me where I am going wrong with this?

注:我使用的是常规的前pression验证的文本框。我把这个在ValidationEx pression。

Note:I am using a regular expression validator for a text box. I have placed this in the ValidationExpression.

推荐答案

没有指定它有问题,因为字符串的结尾。

It was having problem as end of string was not specified.

替换本,

(^\d{1,3}[A-Z]{0,3}$)|(^\d{1,3}[A-Z]{0,3}\/\d{0,3}[A-Z]{0,3}$)

希望这有助于。

Hope this helps.

这篇关于普通EX pression问题时,验证“/”字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 11:32