Extr number from string

I need to extract number from a string and the number may be of decimal type(6.5) or ranged number(7-3) or just a number

Hey @Yashas_H

Regex would work here

So basically those 3 varies for string right

Yes @nikhil.girish

Any 3 types might be there In my string

Got it

((\d+.\d+)|(\d+-\d+)|(\d))

Can you please check this

1 Like

Sure will check this

should have \ before "." otherwise it can match strings like 6a5 6b5 etc.

((\d+\.\d+)|(\d+-\d+)|(\d))

1 Like

Hello @Yashas_H , Kindly try this
[\d+.-]+

System.Text.RegularExpression.Regex.Match(YourString,"[\d+.-]+")
.ToString.Trim

image

1 Like

All the expression mentioned above works thanks guys

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