Hi i need help ...i want regex expression to get names and percentage for examples nikhil-89.65 like this

Hi @katta_nikhil

How about this expression

System.Text.RegularExpressions.Regex.Match(YourString,"\d.+").Tostring

System.Text.RegularExpressions.Regex.Match(YourString,"\S+(?=\swith)").Tostring

Regards
Gokul

Hi @katta_nikhil

You can also try with Split method

Split("nikhil with 89.65","with")(0)
Split("nikhil with 89.65","with")(1)

image

HI @katta_nikhil

You need output like this nikhil-89.65 you can try with this expression

System.Text.RegularExpressions.Regex.Replace(YourString,"\swith\s","-").Tostring

Hi @katta_nikhil ,

Maybe you could also try with a Regex Replace if the pattern is always the same :

(.*)(\swith\s)([0-9.,]+)

Expression :

System.Text.RegularExpressions.Regex.Replace(wordText,"(.*)(\swith\s)([0-9.,]+)","$1-$3")

image

Let us know if the data differs and if so provide us a sample where the regex provided is failing.

1 Like

hi … i known how to do with split method… but i am leraning the regex expression so …

Hi @katta_nikhil

I have also mentioned the Regex expression in the above post. Check it out.

For Learning Regex check out the below tutorial

Regards
Gokul

1 Like

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