Regex Based Extractor issue

As I am using Regex based extractor. In the text file I have a field name Time which is repeated thrice and I need to extract the first occurrence for one Field and second Occurrence for another field. But I don’t know how to specify.

Hi @agathiyanv ,

Could you provide us with the Sample data and the Regex Expression that you have used ?

Maybe also provide us a Screenshot of the Regex Based Extractor’s Configuration.

Document/Message Date: 04/04/2022

Time: 12:45

Booking Date: Delivery Date:

04/03/2022 04/04/2022

Time: 11:15

(?<=Time:)(.*)

Hi @agathiyanv ,
image

This expression will give you all the match in a collection.
Expression: (?<=Time:).*

Now if you want first and second occurrence the extract the first and second values of the collection by:
result_collection(0).toString-----will give you first occurence.
result_collection(1).toString-----will give you second occurence.

Note:
result_collection------the collection with regex matches.

thanks & Regards,
Shubham Dutta

but I am using Regex based Extractor.

Hi @agathiyanv ,
Yes the output will be same just apply this with your variable in place of result_collection
result_collection(0).toString-----will give you first occurence.
result_collection(1).toString-----will give you second occurence.

Hi @agathiyanv

This expression will take the first occurrence

(?<=Time:\s)\S+(?=\n)

or

(?<=Time:\s)\d.{2}\d{2}(?=\n)

image

This expression will take the Second occurrence

(?<=\d{4}\s\d{2}.\d{2}.\d{4}\n\nTime:\s)\d{2}.\d{2}

image

Regards
Gokul

Hi @agathiyanv ,
for your reference am providing a sample workflow.
I hope it will help you.
Regex.xaml (5.4 KB)

Thanks & Regards,
Shubham Dutta