Reputation: 12296
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.
Upvotes: 0
Views: 39
Reputation: 136
Try this:
(\w+\.[a-zA-Z]{2,3}).+?(\d+)\s+ms
Should work.
Demo: https://regex101.com/r/qI0xN6/1
Upvotes: 1
Reputation: 5702
the following seems to work
(\w+\.\w+) : .*, ([0-9]+) ms
Tested here
Upvotes: 1
Reputation: 87233
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 digitsUpvotes: 2