Multiple regex patterns in single regex

string can be either this

WorldScale 115.00 - Overage 50% (Flat rate basis 2019 WS)

or

WS 115.00 - Overage 50% (Flat rate basis 2019 WS)

I need to extract the number written after WS or worldscale or WORLDSCALE that is 115.00 here
I am using this regex
ā€œ((?<=WS)[\d .]+)|((?<=WORLDSCALE)[\d .]+)ā€

but its not giving right results

Hello @Gaurav_Bahuguna
The reason its not working is in your pattern all the letters in the word WorldScale is in Upper format where as in your string its in Proper Case Format

Use this pattern
(?<=WorldScale )\d+\.\d+|(?<=WS )\d+\.\d+

1 Like

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Match(s,"(?<=(WS|WORLDSCALE)\s*)[.\d]+",Regexoptions.IgnoreCase).Value

Regards,

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