Skip to content

Instantly share code, notes, and snippets.

@fredj
Created October 5, 2012 12:19
Show Gist options
  • Select an option

  • Save fredj/3839504 to your computer and use it in GitHub Desktop.

Select an option

Save fredj/3839504 to your computer and use it in GitHub Desktop.
AWB (Air waybill) number validation
import re
def valid(awb):
match = re.match('\d{3}(?P<serial>\d{7})(?P<check>\d{1})', str(awb))
if match:
serial, check = map(int, match.group('serial', 'check'))
_, rem = divmod(serial, 7)
return rem == check
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment