How to get titles in different style using regex

By using 1 expression across, I want to get the titles (e.g. Mr, Mrs, MR etc) and count how many passengers’ names are there.

Text 1:
SINGAPORE AIRLINES LIMITED Electronic Ticket Recelpt: 618 25088985899 SANJAYA/EKA BUDI MR MAHARANIRINI MRS 8ooking Reierence: 77MBJU Date ol Issue: 18 Dec 2016 Frequent Flyer Number: Place of Issue: YMR Tourliner Yogyakarta Indonesla Flight Details Ticket Number: 618 25088985899 SQ 963 Operated by Singapore Airtines Economy Class (Q) From: Jakarta (CGK-Soekamo Inti) Terminal: 2F Depart Sat, 29 Dec 2016 18:00 Status: Contirmed To: Singapore (SIN-Changl) Terminal: 3 Atrive: Sat, 29 Dec 2016 20:45 Stopovers: 0 Not Valid Belore: 20 Dec 16 Nol Vald Alter: 20 Dec 16 Baggage Allowance: 2 Pes SQ 638 Operated by Singappre Aidines Economy Class (Q) From: Singapore (SIN-Changi Intl) Termiral: 3 Depart Sat 29 Dec 2016 23:55 Status: Confirmed To: Tokyo (NRT-Narita Intl) Terminal. 1 Arrive: Sun, 29 Dec 2016 ,07:30 Stopovers: 0 Not Vaid Eefore: 20 Dec 16 No! Vafd Aher: 20 Dec 16 Baggage Allowance: 2 Pcs Payment Details Fare: 4000000.00 IDR For of Payment 1: CCAX 6182000.00 IDR Forn el Paymen: 2 FTAGT05977011 0.00 IDR Tax: YO 1 65000.00 IDR Rostrictions: NO REF AT ANYTIME NON END/EARN KF MILES YO2 65000.00 IDR ONLY-BG SQ YC 1 820000.00 IDR YC2 820000.00 USD SG 1 28000.00 USD SG 2 28000.00 USD 00 1 28000.00 USD OO 2 28000.00 USD DS 1 150000.00 USD D5 1 150000.00 USD Total: 6182000.00 IDR Important Notices Please bring along this receipt during your travel fin case any third party requres proof of purchase). and have all vaild travel documents (e.g. visa and passport) with you. Flight deparlure and arrival timings, Including information regarding the airport lerminal is available via the FEght Stalus page on aur websito. SIA rights departing from Singapore wil depart from either Terminal 2or Terminal 3, as indicated on your E-licket receipt. For SIA llights arriving inlo Singapore. the arrival lerminal wil be conffmed approximately 2 hours belore the actual tme of arrival. The arrival terminal informatlon is available at www.singaporeair.com and the llight enquiry hotline at 1800-5424422 {within Singapore). For changes to your travel plans. please contact the Singapore Airines office nearest to you. Service tees for bookings. ticketing and ticket changes may apply. Contact detals and service fees detalls are aalable on our webxle wv.singaporealr.com… Fox tickets sold in USA and only tor tights departing from and aurring In USA fees for cancefations made within 24 hours ol Initial ticket Issuance may be valved.

Text 2:
Booking Date: 15 March 2021 Scoot Booking Peference scoot XCM9KA Your Itinerary Details Booking Status: Plaase check your fight and nole the departure Nms. tn some inslances, your Hight may be just oler midnighl; which means that you octuaily have lo be ortl the airport the day betore your night dote. Senofe ehsck in couniers open $ hours befers scheduted daperture fer 8787 fighls. and 2.6 houss belore sehoduled dopertuel for A320 fightsa They elose 60mims belore ssheduled deporturo wiih no exeeptione, We recommend Chat you be al the airport at least 90 minutes before departure time. Extra iime would need to be Iaken inlo consideration in case of congestion at the alrpon. Web Checkinis availablo on salecied dights balwonn 72 houn and 1 hours to doparturo ct chockn.ftycoot.com. Recd moro) Checked Baggage:For each checked baggoge. the sum of the length, width and helght shorld ttexceed 158cm. (62 Inches). (Neod mpre) Cabin (2) plocos of Canyon luggage nol DAceeding lhe cmansions of 54om x 38om X 23cm por ploco, wilh D moodmtum lotal combinned welght ol 1oxg. < Read moro) Nele: Consumplion of outside food & boverdges is not alowed on board Sccol rtights. 1 Deparlt Surabarya fo Talpel RyBa ghat TR 266 Scool A320 = 2 h 20 mia Deport Surabaya (SUB) 09:55 Checiln tie : Fri 25 Mer 2021 07:25 Suraboya " Juendo Inl Alpport Termingl: 2 26 March 2021 Fare Class: w1 Amive Singopore (SIN) 13:15 Singopors = Changl Airport Torminal 1 28 March 2021 Layever time : 11 hi 45 min mR BOa Secot 78A-TPE ) = 4 h 35 min Dapart Singapore (SIN) 01:00 Singupore = Changi Airport Teminal 1 27 Moreh 2021 Chectin tamme : Fil, 26 Mot 2021 22:00 Arive Taipel (PD) 05:35 Fore Closs: wl Talpel = Taoyuen InH Atport Tareninal 1 27 March 2021 Al fimos displayed oro Aocol Passenger on thie flight SUB = SIN (TR265) Seal NriFFlyer Baggage Meo’ WiS Snoaze KO Number Mrs Nanda Romadhona 18A 40kg MS90 SIN = TPE (TR898) Soci XriuPyor Baggogo Mools WIS Snoazs Ki Number Mrs Nanda Romadhona 18A 40kg MS9O Al menu items dre subjecl to availablily. Meal opiions my change "ScoolPlus Includes 30mb of WiF and Piority Boording to Ihe dircroft Booking Flexibility Booking Fexibility purchosed for 00 passengor/s at 0.0OIDR por Passengor You wii be able to moie one FREE tight date/ change up to 4 hours befoe you ty wtthout paying standard change tees. fore diferences may apply when changing to a higher (are.

Text 3:
Booking no. Booking date Arfsia SZJ8SL 04 Feb 2023 Travel itinerary Flight 1 Thu, 23 Mar 2023 1 hours 5 minutes X 12: Singapore (SIN) T4 9 13:15 Kuala Lumpur (KUL) KLIA2 + AK 706 1 hours 5 minutes Flight 2 Fri, 24 Mar 2023 1 hours 10 minutes X 20: 45 Kuala Lumpur (KUL) KLIA2 9 21:55 Singapore (SIN) T4 + AK 721 1 hours 10 minutes All times shown are local time Guests AK 706 Low Fare Mr. Gerald Tan Wei Chong + AK 721 Low Fare (Promo) Mr. Gerald Tan Wei Chong Entry Guidelines Kindly check that you adhere to the requirements and regulations set by the local governments of your respective international destinations. The Malaysian Government has made it MANDATORY for all incoming passengers including Malaysians to download and activate the MySejahtera mobile app before departing to Malaysia.Prior to your departure and post-arrival, you may be required to fulfil a number of requirements, including proof of vaccination, health declarations, special passes, pre and post arrival COVID-19 test results, quarantine upon arrival, COVID- 19 insurance (not required effective 1 May 2022) and daily self assessments. You may also be required to download certain mobile applications prior to arriving at your destination. To ensure the highest safety standards, guests are highly encouraged to: Perform mandatory self check-in via the airasia Super App to minimise physical contact. Be certain that you’re not experiencing COVID-19 symptoms, such as fever, cough, sore throat, runny nose or any respiratory symptoms. You are required to wear a mask when flying with AirAsia. For the safety of our guests and crew, we don’t allow masks with exhalation or breathing valves as they are less effective in preventing the spread of COVID-19. Refrain from flying if you’ve had contact with a person with a confirmed or suspected case of COVID-19 or someone with a stay home order within the last 14 days. For the latest, and verified information in your destinations, we strongly encourage all travelling guests to check the travel restrictions with the respective government of your origin and destination country / state directly, prior travelling with us. Local travel restrictions: We encourage you to be aware of the entry and health requirements of the countries you’re travelling from and to: Malaysia, Singapore Travel Insurance: The Malaysian government requires all foreign travellers entering Malaysia to have an insurance policy. It must cover at least MYR 100,000 for COVID-19 healthcare expenses. Get your insurance that meets this requirement now. Boarding: Please be at the boarding gate at least 20 minutes before the scheduled time of departure or you’ll be denied boarding. To maintain social distancing during boarding, we’ll board guests from the back to the front and temporarily halt Xpress Boarding. Meals: Anda boleh membuat pre-book hidangan panas selewat-lewatnya 24 jam sebelum waktu berlepas dan snek tersedia untuk pembelian di dalam pesawat. Wear a face mask: You’ll need to bring your own mask (preferably three-ply surgical or N95 masks). You’ll need to wear it during and after your flight, including during check-in and bag collection. Travel disruptions: It’s important that you update your contact details so we can keep you informed on any flight disruptions or changes. For assistance, please chat with AVA or contact us via WeChat, Facebook and Twitter (if you’re flying to or from China, Hong Kong, Macao or Taiwan). Travel documents Make sure that your passport is valid and that you have all the relevant documents, including visas, entry permits etc., for the destination you’re flying to. You may be denied boarding, detained or deported by the respective authorities if you fail to meet these requirements. Check-in information Self check-in 14 days before your departure via our website, mobile app or airport kiosks. Baggage drop and check-in counters opening and closing times: Domestic flights: Opens: 3 hours before departure (from Kuala Lumpur), 2 hours before departure (from other airports) Closes: 1 hour before departure (from Kuala Lumpur), 30 minutes before departure (from Japan), 45 minutes before departure (from other airports) International flights: Opens: 3 hours before departure Closes: 1 hour before departure Check-in deadlines may vary at different airports and for particular flights. Baggage informationChecked Baggage: You can pre-book up to 40 kg of checked baggage allowance per way for each guest. However, each piece of baggage must not weigh more than 32kg. There’ll be excess baggage fees if the weight of your bags exceed your allowance. You can combine your checked baggage allowance with other guests travelling under the same booking number. Cabin Baggage: You’re allowed to carry one cabin bag (56 cm X 36 cm X 23 cm) and one small bag (40 cm X 30 cm X 10 cm). The total permitted weight for the two pieces must not exceed 7 kg. Read more. Prohibited items: When packing your bags, please keep in mind of items that are prohibited from being carried in your baggage and regulations on the carriage of liquids, aerosols and gels.

Hi @helpplease

Try this Regex Expression:

\b(?:MR|MRS|Mr|Mrs)\b

Hope it helps!!

1 Like

Hi @helpplease


hope this helps for all the text

check this once
System.text.regularexpression.regex.matches(“yourstring”,“\b(?:\sMR|MRS|Mrs|Mr)\b”)

This will give you the output as matchCollection

check this once
System.text.regularexpression.regex.matches(“yourstring”,“\b(?:\sMR|MRS|Mrs|Mr)\b”).count
Gives you the count

1 Like

Hi @helpplease

If you are happy with the solution please mark it as solution to close the loop.

Regards

If I use that expression, it will show 2 but text 2 is one passenger & text 3 is one passenger.

For the third text
You can use

System.text.regularexpression.regex.match(“yourstring”,“\b(?:\sMR|MRS|Mrs|Mr.)\b”).value

Gives you only the first matched value.

Hi @helpplease

Use this regex expression:

b(?:MR|MRS|Mr|Mrs)\s[A-Za-z]+\s+[A-Za-z]+\b

Use this in Assign activity:

System.Text.RegularExpressions.Match(yourstringinput,"b(?:MR|MRS|Mr|Mrs)\s[A-Za-z]+\s+[A-Za-z]+\b").Value

This is give you first Match value.

Hope it helps!

is there a way to make UiPath differentiate the names?

For example, if match 1 and match 2 are different then count as per normal, if match 1 & 2 are the same, count as 1

Text 1: (2 passengers)
SINGAPORE AIRLINES LIMITED Electronic Ticket Recelpt: 618 25088985899 SANJAYA/EKA BUDI MR MAHARANIRINI MRS 8ooking Reierence: 77MBJU Date ol Issue: 18 Dec 2016 Frequent Flyer Number: Place of Issue: YMR Tourliner Yogyakarta Indonesla Flight Details Ticket Number: 618 25088985899 SQ 963 Operated by Singapore Airtines Economy

Text 2: (1 passenger)
Al fimos displayed oro Aocol Passenger on thie flight SUB = SIN (TR265) Seal NriFFlyer Baggage Meo’ WiS Snoaze KO Number Mrs Nanda Romadhona 18A 40kg MS90 SIN = TPE (TR898) Soci XriuPyor Baggogo Mools WIS Snoazs Ki Number Mrs Nanda Romadhona 18A 40kg MS9O Al menu items dre subjecl to availablily. Meal opiions my change "ScoolPlus Includes 30mb of WiF and Piority Boording to Ihe dircroft Booking Flexibility Booking Fexibility purchosed for 00 passengor/s

Text 3: (1 passenger)
hours 10 minutes X 20: 45 Kuala Lumpur (KUL) KLIA2 9 21:55 Singapore (SIN) T4 + AK 721 1 hours 10 minutes All times shown are local time Guests AK 706 Low Fare Mr. Gerald Tan Wei Chong + AK 721 Low Fare (Promo) Mr. Gerald Tan Wei Chong Entry Guidelines Kindly ch

Hi
You can use matches
It will gives you the output as match collection
2.use this

MatchcollectionVariable.Select(Function (x) x.tostring).distinct().toarray.count

Gives you the count

Hope this helps

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