How to use Regex for this sentence

I want to extract the text in between last occurrence of sent to & as on
What will be the regex code for this…
The answer must be
9876_India
9876_Bangalore Electronic City 17

This test session has been sent to 9876_India and except the cases that related to be and has been sent to 9876_India as on the way.

This test session has been sent to 9876_Bangalore and except the cases that related to be and has been sent to 9876_Bangalore Electronic city 17 as on the way.

Hi @Praveen_Vs

9876_india is the static output?

Do you have any static value in the input?

You can try with regex expression @Praveen_Vs

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=sent\sto\s)\d{1,6}\w\S+(?=\sas\son)").Tostring

image

The text in between sent to & as on will be dynamic.

HI @Praveen_Vs

Try this

System.Text.RegularExpressions.Regex.Match(StrVariable,"(?<=sent to )\S+(?=\sas on)").ToString

image

Regards
Sudharsan

Check out this expression @Praveen_Vs

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=sent\s+to\s+).*?(?=\s+as\s+on)",System.Text.RegularExpressions.RegexOptions.RightToLeft)

Regards,