Suppose we have an IP address such as: 192.168.1.1/24
, how to find the network address from this address?
I tried to cut out the IP address to replace the last character by 0
, but it isn't working.
$('.ip').val().replace($('.ip').val().split('/')[0].split('.')[3], 0);
Where $('.ip')
is the selector of an input whose class name is ip
.
Returns 092.168.1.1/24
. The expected result is rather this : 192.168.1.0/24