Regex to extract repeating pattern

Hi,

I have the data where the Pattern will repeat but values will change. I am trying to extract this data using Regex but not able to capture the repeating pattern.
Currently there are only 2 records but it might occur multiple times. I need to extract Company Name & Company ID and the data present in the next line under Death Notifications. Kindly help me to resolve this.

Death Notification(DNE) Post Date: 11-17-2022
Page: 2 of 12

Tr Cd Account Number Name Trace Nbr SSN Date of Death Amount Corrected Information

CompanyName: ABC DEF GHI CompanyId:******1234 SecCode:DNE PostDate:11-16-2022 DescData:

23 12345678901 XYZ WGT S 09876543210 *--1234 11-10-22 2106.00

CompanyName: JKL DEF GHI CompanyId:******5678 SecCode:DNE PostDate:11-16-2022 DescData:

24 09785643210 HGT BHU 12345678901 *--1230 11-10-22 2106.00

Hi,

What values are you trying to extract here?

Hi @sneha_arbole1

For Company Name use this

(?<=CompanyName:).*(?=CompanyId:)

For Company ID use this

(?<=CompanyId:).*(?=SecCode:)

And for getting next line of death notification use the below expression and then use a split activity to get the second line after split

(?<=Death Notification).*\n.*

Once you get the match say its stored in a match variable x then x.Trim.Split({Environment.Newline},StringSplitOptions.None)(1)

If you have any questions please let me know

cheers

Hi @sneha_arbole1

How about this expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=CompanyName:\s)\S.*(?=CompanyId)").Tostring

image

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=CompanyId:).*(?=SecCode)").Tostring

image

Regards
Gokul

Hi @sneha_arbole1

Check out the XAML file

MatchesRegex1.xaml (14.4 KB)

image

image

Regards
Gokul

We can get Company name & Company ID under other sections as well. We need to get these data restricted to the Death Notification

I am trying to extract Company Name & Company Id & line below it under Death Notification

Hi @sneha_arbole1

Can you show where else it can come and will it come in same order?

Under death notification how many lines are valid to check the comapny id or name?

cheers

There will sections like Returns where i will get Company Name &ID in same order.

HI @sneha_arbole1

Then first use a regex to identify the data between death notification and returns using the following

(?<=Death Notification)(.|\s)*(?=Returns)

then from output using the above regular expressions already provided you can extract the company name and id

Hope this helps.Let me know if this does not solve

cheers