I had like to pass the following string via Regex to extract the domain name and the numeric value next to ms.
stackoverflow.com : [0], 96 bytes, 223 ms (223 avg, 0% loss)
I need:
stackoverflow.com , 223
Any help will be much appreciated.
Use following regex
:
(\w+\.[a-zA-Z]{2,3}).+?(\d+)\s+ms
Explanation
()
: Capturing group \\w+
: Match any alphanumeric characters any number of times \\.
: Match .
literal [a-zA-Z]{2,3}
: Match the two or three alphabets .+?
: Matches any characters except linebreak \\d+
: Matches any number of digits
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.