我希望能够从字符串中提取某些内容,例如数字,在速度和准确性方面执行此操作的最有效方法是什么?字符串操作:从java中的字符串中取出数字?
因此,举例来说,如果我有一个文件:PingFile.txt在认为其内容在像管道的服务器只是平:
PING google.com (74.125.224.46): 56 data bytes
64 bytes from 74.125.224.46: icmp_seq=0 ttl=45 time=5.134 ms
64 bytes from 74.125.224.46: icmp_seq=1 ttl=45 time=5.102 ms
64 bytes from 74.125.224.46: icmp_seq=2 ttl=45 time=5.062 ms
64 bytes from 74.125.224.46: icmp_seq=3 ttl=45 time=4.988 ms
64 bytes from 74.125.224.46: icmp_seq=4 ttl=45 time=5.368 ms
64 bytes from 74.125.224.46: icmp_seq=5 ttl=45 time=5.012 ms
如果我想只提取时间值(5.134,5.102 ,5.062等),然后解析它们浮动或双打而不是它们的字符串。我将如何做到这一点?
感谢,
Euden
你是否已经开始编写代码了? –
你尝试过什么吗? – Kiril
定义“最佳方式”。你在寻找速度,可读性还是别的什么? – rretzbach