javascript - 如何从 ip 地址 javascript 等格式中获取最后一位数字?
问题描述
有谁知道我怎样才能得到最后一位数字192.168.1.180
示例: 192.168.1.180 从这个 IP 地址我想提取 180。
提前谢谢
解决方案
好吧,如果那个 ip 地址是一个字符串,你总是可以使用 split 函数。
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)
推荐阅读
- xquery - prolog 中声明的 URI 字符串变量返回错误“不是 xs:anyURI 的子类型”
- permission-denied - Python copyfile() 权限被拒绝
- ios - 如何解决 iOS 13 中的“showsSelectionIndicator”?
- c# - 不和谐机器人只显示不和谐版本
- django - 如何用heroku TypeError解决这个问题:'set' object is not subscriptable
- imagej - 删除或最小化图像中的重叠
- php - 结果没有记录,但记录在数据库中可用
- flutter - 您如何为常量类创建飞镖父级
- python - 为什么python插入反转了第二个列表的内容?
- javascript - 表中的多个复选框值存储在数组中并将数组发送到烧瓶