Skip to content

Instantly share code, notes, and snippets.

@wheresalice
Created August 6, 2011 12:46
Show Gist options
  • Save wheresalice/1129313 to your computer and use it in GitHub Desktop.
Save wheresalice/1129313 to your computer and use it in GitHub Desktop.
Regex to parse an ATCO CIF Bus Service
service = "QSNKDT E91F220080427300001010000010 696 0 I"
service_exception = "QE20100920201009240"
service_origin = "QO450024175 1725 T1F0"
service_destination = "QT25001940 1649 T1F0"
service_regex = /^QS([NDR])(.{4})(.{6})(\d{8})(\d{8})([01]{7})([SH ])([ ABX])(.{4})(.{6})(.{8})(.{8})(.)$/
service_exception_regex = /^QE(\d{8})(\d{8})([01])$/
service_note_regex = /^QN(.{5})(.{72})$/
service_origin_regex = /^QO(.{12})(\d{4})(.{3})(T[01])(F[01])$/
service_intermediary_stop_regex = /^QI(.{12})(\d{4})(\d{4})([BPSN])(.{3})(T[01])(F[01])/
service_destination_regex = /^QT(.{12})(\d{4})(.{3})(T[01])(F[01])/
location_regex = /^QL([NDR])(.{12})(.{48})(.)(.)(.{8})/
location_information_regex = /^QB([NDR])(.{12})(.{8})(.{8})(.{24})(.{24})/
vehicle_type_regex = /^QV([NDR])(.{8})(.{24})/
service.scan(service_regex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment