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
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?
Yoichi
(Yoichi)
March 19, 2021, 8:47am
4
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
as you can see, I still got error… and this is my variable
Regards.
Yoichi
(Yoichi)
March 19, 2021, 9:14am
6
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?
Yoichi
(Yoichi)
March 19, 2021, 9:23am
8
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
system
(system)
Closed
March 22, 2021, 9:24am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.