Does anyone know how can I get the last digits 192.168.1.180
Example : 192.168.1.180 from this ip address i want to extract 180.
Thanks in advance
Asked
Active
Viewed 1,197 times
-7

pradip shinde
- 576
- 1
- 8
- 24
-
what have you tried so far? – toskv Aug 04 '18 at 10:35
-
Possible duplicate of [How do I split a string, breaking at a particular character?](https://stackoverflow.com/questions/96428/how-do-i-split-a-string-breaking-at-a-particular-character) – Aug 05 '18 at 21:15
2 Answers
3
Well, if that ip address is a string you could always use the split function.
let str = "192.168.1.180";
let x = str.split(".")[3];
// where str is the ip and x is the last part you want to extract
console.log(x)

Luca Kiebel
- 9,790
- 7
- 29
- 44

Blackthorn
- 54
- 3
1
Use:
let ip = '192.168.1.180';
let last = ip.split('.')[3];
console.log(last); // '180'

Syed Kashan Ali
- 653
- 4
- 8