How to extract number before percentage symbol using regex?

For eg I have
string=46 % of 62GiB
I want number before % i.e 46
how to write regular expression for this?
Please help?

@vnsatyasunil

System.text
Regularexpression.regex.match(strinput,“\d+”).ToString


Or try below

System.text
Regularexpression.regex.match(strinput,“.*(?=%)”.ToString

@vnsatyasunil

(\d+)(?=\s+%)

Str_out=System.Text.RegularExpressions.Regex.Match(Input,“(\d+)(?=\s+%)”).Value

Include Slash \ before % it will not updated while i put it to you

grafik

 System.Text.RegularExpressions.Regex.Match(YourStringVar, "\d+(?= \%)").Value

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

Thanks. How to check if percentage is in between 50-90% in if condition

Hi @vnsatyasunil

If condition

Output >Cdbl(50) and output <Cdbl(90)

error is option strict on disallows implicit conversions from string to double

@vnsatyasunil

Can you use like below

Cdbl(output)>50 and Cdbl(output)<90

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