Extract a specefic string from a string line

Hello Guys,
I wan to extract the information (in strong) from every line such as:

RATES1…23 % - 1 932/mm3 3124083560 ’ 2583 => 23 % extracted

RATES2 : 19.5 % soit 1.44 G/L (1.34−3.92) 1.44 => 19.5 extracted

RATES1 and RATES2 are random

any suggestion please

Hi,

Hope the following helps you.

System.Text.RegularExpressions.Regex.Match(strLine,"[\.\d]+\s*%").Value

If you don’t need % , the following expression will work.

System.Text.RegularExpressions.Regex.Match(strLine,"[\.\d]+(?=\s*%)").Value

Regards,

1 Like

\d+\s{0,3}% use this expression!
cheers @abdel

Thanks it works!

i had another issue about extracting a date from a string :slightly_smiling_face:

the Following regex: (\d{1,4}([.-/])\d{1,2}([.-/])\d{1,4}) works perfectly with for exemple:

Prélevé le 08/04/19 0 13H01 => it gives 08/04/19

but for:

Prélèvement du : 01−08−2019 11:00 /VV −

it did not work!

\d{1,2}.\d{1,2}.\d{1,4}
try this!

hello it works!

and if i wat to extract from:

blalalalalala: 390 G/L ou Milliers/mm3 (172-398) 384 => 390 G/L
blala: 461 G/L ou Milliers/mm³ (172−398) 461 => 461 G/L
blalala 189 000/mm3 1500000450000 173000 => 189 000/mm3
blalala 265 G/l 150 à 400 259 => 265 G/l

Hi,

How about the following expressions?

Prélèvement du : 01−08−2019 11:00 /VV −

System.Text.RegularExpressions.Regex.Match(strData,"\d{1,2}\W\d{1,2}\W\d{1,4}").Value

blalalalalala: 390 G/L ou Milliers/mm3 (172-398) 384 => 390 G/L
blala: 461 G/L ou Milliers/mm³ (172−398) 461 => 461 G/L
blalala 189 000/mm3 1500000450000 173000 => 189 000/mm3
blalala 265 G/l 150 à 400 259 => 265 G/l

System.Text.RegularExpressions.Regex.Match(strData,"\w+\s*\w+/\w+").Value

Regards,