首页 > 解决方案 > 从java中的字符串中提取mac地址

问题描述

这里的例子,
`String test = " link/ether 00:0c:29:d1:86:4e brd ff:ff:ff:ff:ff:ff";

00:0c:29:d1:86:4e 是 Mac 地址。我应该如何提取 MacAddress 并且 MacAddress 的位置不是静态的?

提前致谢!!

标签: java

解决方案


String test = "  link/ether 00:0c:29:d1:86:4e brd ff:ff:ff:ff:ff:ff";
String[] tokenizeString = (test.trim()).split(" ");
System.out.println(tokenizeString[1]); //From question you are intrested on this stuff only

我知道这会解决你的问题!!!


推荐阅读