Regular expression extraction


#1

I have an data which may vary in each other place like Qty-35 or 35 Cpy or 35, I need to extract the only numbers from this data please help me in providing the appropriate Syntax or Regular Expression in extracting only the number.


Extract specific value
#2

string v1 = "Qty-35 or 35 Cpy or 35"

assign v1 = System.Text.RegularExpressions.Regex.Match(v1,"\d+").value

you can get result 35


#3

Actually these data whichever mentioned is in the body of the mail and it may be like
Norton Callen’s Ultrasonography in Obstetrics and Gynecology:
First South Asia Edition
Qty - 34
in one mail body and
Whereas,
Basic Immunology : Functions and Disorders of the Immune
System (First South Asia Edition PB—Abbas— 1 copy
In another mail body.
Please help me in extracting only the number


#4

This Regex pattern will give you numbers only : \d+

Regex.Match(your_Mail_body_String, “\d+”).Value

\d with + quantifire Matches between one and unlimited times, as many times as possible, giving back as needed by following greedy approach :slight_smile:

Regards…!!
Aksh


#5

Hi,
I want to extract specific value from mail body

9788131247006Norton Callen’s Ultrasonography in Obstetrics and Gynecology:
First South Asia Edition
Qty - 34
Need urgent delivery for this order.

Out of this mail body I need to extract quality value
Output should be
o/p:
34.
Please help.


#6

It is Duplicate so Merged.

Question is here it is an Assignment?
-You should try it by yourself it will be beneficial for you only. A humble advice :slight_smile:

and other thing Number you want always after Qty Field?

or you just wants any number like 34,9788131247006?

Regards…!!
Aksh


#7

I want always after Qty Field.

Regards
Sruthilaya


#8

Try this:-Regex_For_number.xaml (5.8 KB)

Regards…!!
Aksh


#9

thank you its working fine.


#10

@aksh1yadav its not always Qty it might be quantity or copy or copies or cps
for this how can i do.

That is where i am stuck ryt now. I need some help badly


#11

@Kaushik_07

This regex will select every number after SPACE DASH SPACE " - " on the same line:
(?<= - )\d+

This regex will select every character:
(?<= - ).+
(in case you need to match after a comma or dot)

For reference, see it here:
https://regex101.com/r/62MmVa/1