Disk stats Regex

HI Team,

i am doing some automation w.r.t cmd and with the results i obtained in CMD i need to fetch some values

in the resultant text of cmd i need to see word called Disk Stats (red/write) if found i need to extract the second instance of UTIL val which is 100% at the last… i am trying from my end… any guidance from your end would help

Hi @devasaiprasad_K

Try this

Output=If(Input.Contains("Disk Stats(read/write)"),System.Text.RegularExpressions.Regex.Match(Input,"(?<=util=).*").Value,"")

Regards,

Hi @devasaiprasad_K

=> Store your cmdOutput in a variable say cmdOutput.
=> Use an If condition and give like below:

If
  cmdOutput.Contains("Disk Stats (red/write)") 
Then
    Assign -> utilValues = System.Text.RegularExpressions.Regex.Matches(cmdOutput, "UTIL\s*:\s*\d+%")
    (utilValues is of DataType System.Collections.Generic.IEnumerable(System.Text.RegularExpressions.Match))
    
    Assign -> secondUtilValue = If(utilValues.Count >= 2, utilValues(1).Value, "Not Found")
    (secondUtilValue is of DataType System.String)
Else
    secondUtilValue = "Disk Stats (red/write) not found"
End If

Regards

@devasaiprasad_K, This is based on Dynamic you will get all the value on keyword base.

Option 1: (aggutil|Util)=(\d+\.\d+)%
You need to provide the keywords

Option 2: (aggutil)=(\d+\.\d+)%
You need to provide one keyword base

How can we do use implement it in your project?

1 First, read the CMD
2 Read The text via Regex we have added
2.1 Chcek the keyword using contain “Disk Stats (red/write)”
System.Text.RegularExpressions.Regex.Matches("Pass your CMD text",(aggutil)=(\d+\.\d+)%)
**3 ** Save the data in your output

@devasaiprasad_K , We are added the UiPath Xaml file, which return one value, @devasaiprasad_K you need to modify according to your logic or I have updated in steps


Disk_Stats.xaml (6.8 KB)

@devasaiprasad_K you given regex code, First get the data based on key word the you need to use below solution

Regard
Mukesh Singh

even though i keep quantifier as exactly it is still filtering the relative values (aggrutil) i need only util to filter

the same is happening with this expression as well
(?<=util)=(\d+.\d+)

@devasaiprasad_K

Try this

Input="util=100.0%

aggrutil=120.0%"

Output=System.Text.RegularExpressions.Regex.Match(Input,"(?<=util=)\d+").Value

Regards,

@devasaiprasad_K you given regex code, First get the data based on key word the you need to use below solution

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