c# - Regular Expression to Match IP Subnet -
i need c# regular expression match ip subnet, "127.65.231", not match ip address on subnet, "127.65.231.111". had found regex ip address:
@"\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b"
and thinking delete part checks last octet, this:
@"\b\d{1,3}.\d{1,3}.\d{1,3}\b"
but matches both ip address , subnet. can this?
@"^\d{1,3}\.\d{1,3}\.\d{1,3}$"
use line anchors. add ^ @ beginning of regex, , $ @ end, verify beginning , end of input.
this match 127.65.231
not 127.65.231.111
Comments
Post a Comment