Hi Friends,
I am new to regex and I am trying to extract 3 letter station codes from a given string like the one below.
I want to extract only stations that are in the middle of the string not in the beginning or ending??
DFW,Tom branson,0621905,Tom.branson@saansa.com,Positioning for ride home/there/etc. ,10/16/2018,345,SFO,ORD,B737,Compliant,Not observed,Compliant,Not observed,TEAM WAS WELCOMING, PROACTIVE, AND GRACIOUS (WHEEL CHAIR CUSTOMER PRECEDED ME),Not observed,Compliant,Compliant,Compliant,Compliant,Compliant,Compliant,CONTINUOUS WALK THROUGHS - GREAT COORDINATION WITH GROUND STAFF AND COCKPIT,Compliant,Compliant,CONTINUOUS WALK THRUS/ GREAT EYE CONTACT/ GREAT CREW COORDINATION,FA 3,CHARLIE CROOM ,339057,Compliant,Compliant,Compliant,Compliant,Compliant,Compliant,FROM THE FIRST MEETING AT THE BOARDING DOOR TO OUR VISIT IN THE GALLEY,MIA
Thanks,Gs
Solved! Go to Solution.
Do you have anymore data to provide? I’m not sure what is making up your capture/extraction. Are they always together with the commas?
I’ll assume so. Use this regex and it’ll nab what you have highlighted. If there’s more variances, we’ll need more data.
\,([A-Z]{3})\,([A-Z]{3})\,
That will parse what you have in bold.
Thanks a lot.
in the same Example, how do I parse from date to aircraft type 0/16/2018,345,SFO,ORD,B737,
DFW,Tom branson,0621905,Tom.branson@saansa.com,Positioning for ride home/there/etc. ,10/16/2018,345,SFO,ORD,B737,Compliant,Not observed,Compliant,Not observed,TEAM WAS WELCOMING, PROACTIVE, AND GRACIOUS (WHEEL CHAIR CUSTOMER PRECEDED ME),Not observed,Compliant,Compliant,Compliant,Compliant,Compliant,Compliant,CONTINUOUS WALK THROUGHS - GREAT COORDINATION WITH GROUND STAFF AND COCKPIT,Compliant,Compliant,CONTINUOUS WALK THRUS/ GREAT EYE CONTACT/ GREAT CREW COORDINATION,FA 3,CHARLIE CROOM ,339057,Compliant,Compliant,Compliant,Compliant,Compliant,Compliant,FROM THE FIRST MEETING AT THE BOARDING DOOR TO OUR VISIT IN THE GALLEY,MIA
For aircraft type, you have some certain pattern?
Can I get just Date, number, Origin and Destination
10/16/2018,345,SFO,ORD ??
This expression should get you everything but the aircraft type (I labeled the group captures for you to make any tweaks and read easier):
(?<date>\d+\/\d+\/\d+)\,(?<number>\d+)\,(?<origin>[A-Z]{3})\,(?<destination>[A-Z]{3})
Is the aircraft type always following the airport codes? As long as there aren’t any symbols, this should work:
(?<date>\d+\/\d+\/\d+)\,(?<number>\d+)\,(?<origin>[A-Z]{3})\,(?<destination>[A-Z]{3})\,(?<aircraft>\w+)