$ Strsystem (& #039; pingwww.baidu.com & #039;); {code...} I want to intercept the ip address (ip address in []) in it ). There are several ways to ask. I only want regular expressions. However, regular expressions are not yet learned. If you want to write a small function, this problem will not solve $ str = system ('Ping www.baidu.com ');
Pinging www.a.shifen.com [115.239.210.27] with 32 bytes of data: reply from 115.239.210.27: byte = 32 time = 25 ms TTL = 54 reply from 115.239.210.27: byte = 32 time = 25 ms TTL = 54 replies from 115.239.210.27: byte = 32 time = 26 ms TTL = 54 replies from 115.239.210.27: byte = 32 time = 26 ms TTL = 54 115.239.210.27 Ping statistics: Packet: Sent = 4, received = 4, lost = 0 (0% lost ), estimated round-trip time (in milliseconds): Minimum = 25 ms, maximum = 26 ms, average = 25 ms Array
I want to intercept the ip address (ip address in []) in it ). There are several ways to ask.
I only want regular expressions. However, regular expressions are not yet learned.
If you want to write a small function, this problem will not be solved.
Reply content:
$ Str = system ('Ping www.baidu.com ');
Pinging www.a.shifen.com [115.239.210.27] with 32 bytes of data: reply from 115.239.210.27: byte = 32 time = 25 ms TTL = 54 reply from 115.239.210.27: byte = 32 time = 25 ms TTL = 54 replies from 115.239.210.27: byte = 32 time = 26 ms TTL = 54 replies from 115.239.210.27: byte = 32 time = 26 ms TTL = 54 115.239.210.27 Ping statistics: Packet: Sent = 4, received = 4, lost = 0 (0% lost ), estimated round-trip time (in milliseconds): Minimum = 25 ms, maximum = 26 ms, average = 25 ms Array
I want to intercept the ip address (ip address in []) in it ). There are several ways to ask.
I only want regular expressions. However, regular expressions are not yet learned.
If you want to write a small function, this problem will not be solved.
Preg_match ("/\ [(\ d + \. \ d + \. \ d + \. \ d +) \]/"," pinging www.a.shifen.com [115.239.210.27] with 32 bytes of data: From 115.239. ", $ matches );
Print_r ($ matches );
Mixed strpos (string $ haystack, mixed $ needle [, int $ offset = 0])
Find the location where ']' appears for the first time
Then use
String substr (string $ string, int $ start [, int $ length])
Truncate string