Hi team, Pls provide regular expression for the data.Tq

Room 1:
Guest: MISS andrean Roar Rate Breakdown: Double Room Ensuite for Single Occupancy
Nights: 1
Hotel Ref: 9877HBCDFT
Commission: 6.00% Std

Room 2:
Guest: MISS Rebecca Walls Rate Breakdown
Nights: 1
Hotel Ref: 376SFHDR45
Commission: 6.00% Std

Room 3:
Guest: BETH WORDINGHAM Rate Breakdown
Nights: 1
Hotel Ref: 678HGFHDFBD7
Commission: 6.00% Std

Here i want to extract Guest name, Nights, Hotel ref for each Room using regex. Pls provide solution.

Hi @Lokesh_M2

You can use the following RegEx patterns:

Guest:\s+([A-Za-z]+(?:\s+[A-Za-z]+)*)

Nights:\s+(\d+)

image

Hotel Ref:\s+([A-Za-z0-9]+)

Hope this helps,
Best Regards.

1 Like

Thank u for info and also i need to assign extracted data as per Room no.
ex: if it is Room 1
i want to display that particular guest name, hotel ref, nights.

@Lokesh_M2

You can simply put the extracted data in a datatable & filter the datatable based on the room number that want to view.

Hope this helps,
Best Regards.

Thank you. but if Room count is not same for all files. they are dynamic.
ex: For data given there are Rooms 3
For other files Rooms count some other digit

@Lokesh_M2

It doesn’t matter. As long as the the room names (like Room 1 for all data) are same, filter datatable will club all the data in a single block.

Hope this helps,
Best Regards.

Sorry, i didn’t get u.If u don’t mind can u send some sample xaml when u find time.Tq

Hi

Please find the attached file
Strings.xaml (16.7 KB)

Hope this helps

Regards

1 Like

HI,

We can achieve it using single regex. Hope the following sample helps you.

mc = System.Text.RegularExpressions.Regex.Matches(strData,"Room (?<ROOMNO>\d+):\s+Guest:\s+(?<GUEST>.*?)\s+Rate Breakdown:?\s*(?<RATEBREAKDOWN>.*?)\s+Nights:\s+(?<NIGHTS>\d+)\s+Hotel Ref:\s+(?<HOTELREF>\w+)\s+Commission:\s+(?<COMMISSION>.*?)(\r?\n\r?\n|\s*$)")

Then, iterate MatchCollection : mc. Let’s say m as each item.

m.Groups("ROOMNO").Value
m.Groups("GUEST").Value
m.Groups("RATEBREAKDOWN").Value
m.Groups("HOTELREF").Value
m.Groups("COMMISSION").Value

returns each matched string.
The above sample outputs the following sheet , finally.

Sample20230401-5L.zip (3.4 KB)

Regards,

1 Like

Hi @Yoichi, when reading pdf with same data it is not giving any output.

Room 1:
Guest: MISS Sutio Robre Queen Rate Breakdown: Double Room Ensuite for Single Occupancy
Nights: 1 ﴾Dep: 21/01/2022﴿ PER NIGHT STARTING 26 Dec FOR 1 NIGHT GBP89.00
GCINumber: 37463746 SUB TOTAL FOR STAY GBP89.00
ReasonforTravel: TRAINING|CONFERENCE APPROX TOTAL INCL ALL KNOWN TAXES/FEES GBP89.00
Company Name: ASE Technologies Equal Forma Ltd. Meal Plan: Room and full breakfast
Hotel Ref: 56788SD034589
Commission: 4.00% Std
Room 2:
Guest: MR Aderta Brewq Rate Breakdown: Double Room Ensuite for Single Occupancy
Nights: 2 ﴾Dep: 12/04/2022﴿ PER NIGHT STARTING 26 DEC FOR 1 NIGHT GBP89.00
GCINumber: 37463746 SUB TOTAL FOR STAY GBP89.00
ReasonforTravel: TRAINING|CONFERENCE APPROX TOTAL INCL ALL KNOWN TAXES/FEES GBP89.00
Company Name: ASE Technologies Equal Forma Ltd. Meal Plan: Room and full breakfast
Hotel Ref: 56788SD034580
Commission: 4.00% Std
Room 3:
Guest: Allyppe Brode Rate Breakdown: Double Room Ensuite for Single Occupancy
Nights: 1 ﴾Dep: 21/01/2022﴿ PER NIGHT STARTING 26 APR FOR 1 NIGHT GBP89.00
GCINumber: 37463745 SUB TOTAL FOR STAY GBP89.00
ReasonforTravel: TRAINING|CONFERENCE APPROX TOTAL INCL ALL KNOWN TAXES/FEES GBP89.00
Company Name: ASE Technologies Equal Forma Ltd. Meal Plan: Room and full breakfast
Hotel Ref: 56788SD034581
Commission: 4.00% Std
Room 4:
Guest: MR Akalidio Malyal Rate Breakdown: Double Room Ensuite for Single Occupancy
Nights: 1 ﴾Dep: 21/01/2022﴿ PER NIGHT STARTING 26 APR FOR 1 NIGHT GBP89.00
GCINumber: 37463746 SUB TOTAL FOR STAY GBP89.00
ReasonforTravel: TRAINING|CONFERENCE APPROX TOTAL INCL ALL KNOWN TAXES/FEES GBP89.00
Company Name: ASE Technologies Equal Forma Ltd. Meal Plan: Room and full breakfast
Hotel Ref: 56788SR034582
Commission: 4.00% Std
Room 5:
Guest: MR Deio Kook Rate Breakdown: Double Room Ensuite for Single Occupancy
Nights: 1 ﴾Dep: 21/01/2022﴿ PER NIGHT STARTING 26 APR FOR 1 NIGHT GBP89.00
GCINumber: 37463747 SUB TOTAL FOR STAY GBP89.00
ReasonforTravel: TRAINING|CONFERENCE APPROX TOTAL INCL ALL KNOWN TAXES/FEES GBP89.00
Company Name: ASE Technologies Equal Forma Ltd. Meal Plan: Room and full breakfast
Hotel Ref: 56788D034588
Commission: 4.00% Std

After Reading PDF text the is displaying in this format. From here i need to extract
Guest Name, Hotel ref, Nights, Rate break down, Meal plan and TaxS/FEES.
Moreover, For each pdf Room count is varied.
Pls provide solution.Tq

Hi @lakshminarayana_chavala - Please check the attached workflow

SampleWorkflow.zip (3.4 KB)

Output

1 Like

Hi @Yoichi it is working with some modification in regex.Thank you very much for your support and solutions.

1 Like

Hi @ushu, your code working for all pdf files.Tq very much for your work. Moreover, I need put all the data in variables after iterating data like Room, guest name etc. Here it is not working if i take currentitem(0).tostring, currentitem(1).tostring etc. Pls help in this.Tq

Hi @ushu, your code working for all pdf files.Tq very much for your work. Moreover, I need put all the data in variables after iterating data like Room, guest name etc. Here it is not working if i take currentitem(0).tostring, currentitem(1).tostring etc. Pls help in this.Tq
This is the error showing


Pls do provide solution.Tq

@lakshminarayana_chavala - Please try this, currentItem.ToString

ok But, how to store in avariable like guest name, room,hotel ref etc