Regular expression fetching the last value and storing into excel

Hi all,

(?<=Cust Removal\r?\n).*
Above expression matches for Cust Stated Reason for Removal, here in my input file there are 10 matches for this expression what ever it scans at last that is being stored into excel.
Excel should take the first match.
Example:
Cust Removal
Demo sample
Refresh
Cust Removal
WINDOW
Refresh
Cust Removal
Not good
Refresh
Cust Removal
Quality issue
Refresh
Cust Removal
Support
Refresh
What changes i should do in my expression, so that only the first match can fetch and store into excel.
Please help.

Thanks,
Lakshmi

Hello @lakshmi.mp

Does that mean you want to get “Demo Sample” as the output?

You can do as below.

Split(MyString,“Cust Removal”)(1).Replace(“Refresh”,“”)

image

1 Like

@Rahul_Unnikrishnan ,
Yes demo sample is the output.
Thank you for resolving.

Regards,
Lakshmi

1 Like

HI @lakshmi.mp

You can also tr with Regex expression

System.Text.RegularExpressions.Regex.Match(InputStr,"(?<=Cust Removal\n)(\S.+)").Tostring

Regard
Gokul

1 Like

@Gokul001 ,
Thank you for providing another expression.

Regards,
Lakshmi

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