[英]regex for number followed by letters
I am trying get the Regex right for the following scenario but have some trouble. 我正在尝试让正则表达式适合以下情况,但遇到一些麻烦。 Below is the scenario. 下面是方案。
My string looks like this: 141st ST or 141ST ST
我的字符串如下所示: 141st ST or 141ST ST
I want to get only the 141st
part 我只想获得141st
部分
This should work. 这应该工作。
[0-9]{3}[A-Za-z]{2}
3 numbers with 3个数字
[0-9]{3}
1 to 3 digits with 1至3位数字
[0-9]{1,3}
and 2 letters with 和2个字母一起
[A-Za-z]{2}
If you want to be cool you could do it this way to validate the street number too: 如果您想保持冷静,也可以通过这种方式验证街道编号:
\d{0,2}(?:1st|2nd|3rd|[04-9]th)(?= st)
and just use the case insensitive flag 并只使用不区分大小写的标志
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.