How do I get spesic text from the output of a command in Command Prompt

Hi,
I would like to extract only a specified text from the output of a command in Command Prompt.
in the below of image I would like to extract “Number of Pings 8” but the value of Number of Pings is a random value.
What kind of string manipulation that I use?

Thanks!

I am assuming that u are able to extract the text from command line

So to extract the number use the regex like

(?<=Number of Pings )\d+

Regards

Nived N :robot:

Happy Automation

1 Like

Hi @NIVED_NAMBIAR
I use Split for store the output of a Command Prompt.
I got error when using Regex, cau u explain the step?

Hi,

Probably you should write it as the following.

System.Text.RegularExpressions.Regex.Match(getNumOfPings,"(?<=Number of Pings\s*)\d+").Value

Regards,

1 Like

Hi @Yoichi
Thank u for the reply

image

as you can see, I still got error… and this is my variable

Regards.

Hi,

In this case, you dont need to use split method.
Can you try the following?

System.Text.RegularExpressions.Regex.Match(numOfPings.ToString,"(?<=Number of Pings\s*)\d+").Value

Regards,

Hi @Yoichi
Ya its working, but what if I want extract the text “Number of Pings” too?

Hi,

what if I want extract the text “Number of Pings” too?

The following pattern will work. Can you try this?

"Number of Pings\s*\d+"

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.