Help in over my head!

jaymenna78734

New member
Joined
Jan 16, 2005
Messages
2
Sorry to ask, but I am very weak when it comes to RegEx and have a deadline over my head.

A function os returning the following text to me

--- www.XYX.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 165.738/165.827/165.965 ms

I need to parse out just the "3" for both packets transmitted and received.

Thanks!
 
Use Grouping

jaymenna78734 said:
Sorry to ask, but I am very weak when it comes to RegEx and have a deadline over my head.

A function os returning the following text to me

--- www.XYX.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 165.738/165.827/165.965 ms

I need to parse out just the "3" for both packets transmitted and received.

Thanks!

You can use grouping to capture the numbers.

Use the following search string:

(\d+)[ ]packets[ ]transmitted[,][ ](\d+)[ ]packets[ ]received

This will search for the transmitted/received quantities. The first group of parentheses represents group 1 and the second group 2. Inside the brackets is either a single space or a comma. The \d+ means one or more digits. You can then refer to the values of group 1 for the transmitted quantity string and group 2 for the received quantity string.

This may be too general, but you should be able to work this into your application.
 
That does it

Richard Crist said:
You can use grouping to capture the numbers.

Use the following search string:

(\d+)[ ]packets[ ]transmitted[,][ ](\d+)[ ]packets[ ]received

This will search for the transmitted/received quantities. The first group of parentheses represents group 1 and the second group 2. Inside the brackets is either a single space or a comma. The \d+ means one or more digits. You can then refer to the values of group 1 for the transmitted quantity string and group 2 for the received quantity string.

This may be too general, but you should be able to work this into your application.


It was tweakble from here thanks!
 
Back
Top