我有IPv4地址正則表達式分離:正則表達式多個IP逗號具有或不具有子網
^(([0-9] | [1-9] [0-9] | 1 [ 0-9] {2} | 2 [0-4] [0-9] | 25 [0-5])){3}([0-9] |。[1-9] [0-9] | 1 [0-9] {2} | 2 [0-4] [0-9] | 25 [0-5])$
和我有正則表達式的IPv4 CIDR範圍:
^(([0-9] | [1-9] [0-9] | 1 [0 -9] {2} | 2 [0-4] [0-9] | 25 [0-5])){3}([0-9] |。[1-9] [0-9] | 1 [0-9] {2} | 2 [0-4] [0-9] | 25 [0-5])(/([0-9] | [1-2] [0-9] | 3 [ 0-2]))$
的問題是我應該如何使用逗號分隔重複
模式:
XXX.XXX.XXX.XXX,XXX.XXX.XXX.XXX/ XX,XX.XX.XX.XX,XX.XX.XX.XX/X,XX.XX.XX.X 測試數據 -
123.123.13.11, 1.0.0.0, 1.0.0.1/ 3, 1.0.0.0/20
正在使用http://regexr.com/通過正則表達式來打造, 我所要建造的正則表達式是低於而不是working--
/(((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))),?)/g
在逗號分隔,循環並使用您已擁有的正則表達式。 –
這是不行的 - /((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0 -5] | 2 [0-4] [0-9] | [01] [0-9] [0-9])\(25 [0-5] |。[0-4] [O- 9] | [01] [0-9] [0-9])\(25 [0-5] |?2 [0-4] [0-9] | [01] [0-9] [0-9]))/克?; – user7353226
http://stackoverflow.com/a/23483979/797495 –