Private IP Address Identifier in Regular Expression

后端 未结 10 1289
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 09:14

I\'m wondering if this is the best way to match a string that starts with a private IP address (Perl-style Regex):

(^127\\.0\\.0\\.1)|(^192\\.168)|(^10\\.)|(         


        
10条回答
  •  爱一瞬间的悲伤
    2020-12-01 09:53

    FWIW this pattern was over 10% faster using pattern.matcher:

    ^1((0)|(92\\.168)|(72\\.((1[6-9])|(2[0-9])|(3[0-1])))|(27))\\.
    

提交回复
热议问题