String manipulation : Get string between two keywords

Hi Team,

This is my string.

ABC_NA_Final Report_<92765> ._17-10-2023_Selected OR

ABC_NA_Final Report_<78654> ._17-10-2023_Rejected OR

ABC_NA_Final Report_<98545> ._17-10-2023_Pending OR

I need to extract the text between ‘Final Report_’ and ‘._’ i.e 78654,98545,92765

After getting this I need to add all the extracted numbers to datatable for further use. Also the number of lines are dynamic.

Can anyone help please?

1 Like

@Happy_Coding

or

System.Text.RegularExpressions.Regex.Match(Input,"(?<=\_<)\d+(?=\>)").Value
1 Like

Hi @Happy_Coding

(?<=\<)(.*)(?=\>)

Hi @Happy_Coding

(?<=\_<)(.*)(?=\> ._)

Cheers!!

Hi @Happy_Coding


Main.xaml (17.9 KB)
Testingforum.xlsx (8.3 KB)

Regards

@vrdabberu , Thanks for your response.

Can you please help with writing the whole line for regex expression as I am new to regex.

Hi @Happy_Coding

Yeah sure uploading give me 2 mins. You have the complete data in a string variable right.

Regards

Yes , Complete data in a string variable.

Thanks @vrdabberu

HI @Happy_Coding

Please check the below workflow:
In the below flow I have splitted the string dtaa into multiple lines and extracted the data as per your requirement.

Main.xaml (18.4 KB)
Testingforum.xlsx (7.8 KB)


Regards

1 Like

Thanks @vrdabberu , It worked like magic.

I was exactly looking for this. :grinning:

In addition,

How can we extract Selected,Pending,Rejected. :thinking:

1 Like

I tried to modify the existing regex but I am getting some escape character error.

Hi @Happy_Coding

I have given the regex expressions for those and please refer below:

System.Text.RegularExpressions.Regex.Match(Input,"(?<=[A-Za-z]+\_.*\<.*\_)([A-Za-z]+)").Value

Regards

Hi @Happy_Coding ,
you can use regex to get the text .
if the strings are in a array ,
image
for each string ,
use regex to get values


cint(System.Text.RegularExpressions.Regex.Match(currentItem, “<(\d+)>”).Groups(1).Value)
output:
image

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