正则表达式匹配冒号和数字

时间:2013-11-21 10:13:37

标签: regex

我正在编写正则表达式来匹配这样的模式。

abc:123-12-4

abc: It should be exact match including colon
123   Number match any length
-     Exact Match
12    Number Match any length
-     Exact match
4     Exact match 

任何想法如何以更简单的方式完成。

1 个答案:

答案 0 :(得分:2)

您可以使用此正则表达式:

^abc:[0-9]+-[0-9]+-4$