Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3.7
- # -*- coding: utf-8 -*import
- import re
- count = int(input())
- for _ in range(count):
- text = input()
- regex = r'(@[#]+)(?P<barcode>[A-Z]{1}[a-zA-Z0-9]{4,}[A-Z]{1})(@[#]+)'
- match = re.search(regex, text)
- if not match:
- print('Invalid barcode')
- else:
- barcode = match.group('barcode')
- group = ''
- for x in barcode:
- if x.isdigit():
- group += x
- if group:
- print(f'Product group: {group}')
- else:
- print(f'Product group: 00')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement