我是新來正規表達式,請幫我寫一個新的正則表達式。這應該是工作爲這些:RegEx端口枚舉驗證
28
28,57,130
13-18
13,18-57,65
44-56,50-130,150,180-213
12-25,28
1024-8000,27000-30000
1024-65535
它shoudn't爲
15,13 // 13 is less than 15
15-11 // 11 is less than 15
15-18,10
15-18,20,11-130 // because of 11
0 // port number 0 is reserved and can't be used
11-180,250,65536 // it should be less than 65535
正則表達式不適合這個,特別是不適合t第二個列表中數字的比較。如果你只是想檢查你是否有用逗號和/或破折號分隔的數字,正則表達式是好的。 –
@Daniel Persson,現在我明白了,看來我需要使用轉換 –