Forum Moderators: open

Message Too Old, No Replies

truncate an IP based on segment

truncate

         

fiuOY

2:24 pm on Apr 25, 2006 (gmt 0)

10+ Year Member



Hello,

Can somebody help figure out how to truncate a IP address up to the last dot (including the last dot). In other words if I have 195.15.68.199 I want to end up with 195.15.68 but the last part is not always 3 digits. It could be 3 2 or 1 digit.

thank you in advance

jalarie

2:38 pm on Apr 25, 2006 (gmt 0)

10+ Year Member



IP='195.15.68.199';
ix1=IP.lastIndexOf('.');
Result=IP.substring(0,ix1);
alert(Result);