Regex Help-- Unstructured Text File

Hi folks,
I want to write one conditional regex for the below scenario:
I have one text file that is unstructured and i want to extract data
if
REPORT ID: CSS-110 and
REPORTING FOR: 000000000 GSP and ROLLUP TO: 000000 GSP ,SETTLEMENT CURRENCY: EUR ,then capture next all lines till first occurence of character END of Report
Note, this is a big file and end of report can appear multiple time ,ReportID can occur multiple time but the combination of this "REPORT ID: CSS-110 and
REPORTING FOR: 000000000 GSP and ROLLUP TO: 000000 GSP ,SETTLEMENT CURRENCY: EUR " occurs once.
Please help me with regex,

Thanks in adveance :slight_smile:
Digits ,numbers,text are fixed.

Try below regex

(?s)(REPORT ID: CSS-110.*?REPORTING FOR: 000000000 GSP.*?ROLLUP TO: 000000 GSP ,SETTLEMENT CURRENCY: EUR)(.*?END of Report)

Hi @Anjali_Rani

Can you try this

((REPORT ID: CSS-110 and)\r?\nREPORTING FOR: 000000000 GSP and ROLLUP TO: 000000 GSP ,SETTLEMENT CURRENCY: EUR)[\s\S]*(?=END of Report)

Regards,

1 Like

Hi @Anjali_Rani

you can use match activity, check with this expression.

(?<=REPORT ID: CSS-110 and REPORTING FOR: 000000000 GSP and ROLLUP TO: 000000 GSP ,SETTLEMENT CURRENCY: EUR)(.*?)(?=END of Report)

Or like you stored text into “fileConten”
Then you can use in assign activity like:

ExtractedData = System.Text.RegularExpressions.Regex.Match(fileContent, “(?<=REPORT ID: CSS-110 and REPORTING FOR: 000000000 GSP and ROLLUP TO: 000000 GSP ,SETTLEMENT CURRENCY: EUR)(.*?)(?=END of Report)”).Value

Mark as a solution , if you found it helpful.
Happy Automation!