Extracting passenger names from flight information
with strings as (
select 'LHRJFK/010315/JOHNDOE' str from dual union all
select 'CDGLAX/050515/JANEDOE' str from dual union all
select 'LAXCDG/220515/JOHNDOE' str from dual union all
select 'SFOJFK/010615/JANEDOE' str from dual
)
SELECT regexp_substr(str, '[A-Z]{6}') String_of_6_characters,
regexp_substr(str, '[0-9]+') First_Matching_Numbers,
regexp_substr(str, '[A-Z].*$') Letter_by_other_characters,
regexp_substr(str, '/[A-Z].*$') Slash_letter_and_characters
FROM strings
STRING_OF_6_CHARACTERS | FIRST_MATCHING_NUMBERS | LETTER_BY_OTHER_CHARACTERS | SLASH_LETTER_AND_CHARACTERS | LHRJFK | 010315 | LHRJFK/010315/JOHNDOE | /JOHNDOE | CDGLAX | 050515 | CDGLAX/050515/JANEDOE | /JANEDOE | LAXCDG | 220515 | LAXCDG/220515/JOHNDOE | /JOHNDOE | SFOJFK | 010615 | SFOJFK/010615/JANEDOE | /JANEDOE |
---|