forked from miczar1/djfz-24_25
ef7a470ae5
Bore...
15 lines
489 B
Python
15 lines
489 B
Python
import re
|
|
import sys
|
|
|
|
def extract_area_code(line: str) -> str:
|
|
# While this regex seems complicated, it essentially enforces either of two possible formats
|
|
# Returning the area code captured in group(1)
|
|
p = re.compile(r'^[+0](\d{2})\s(?:\d-\d{3}-\d{3}|\d{3}-\d{2}-\d{2})$')
|
|
m = p.match(line)
|
|
return m.group(1) if m else "<NONE>"
|
|
|
|
if __name__ == "__main__":
|
|
for line in sys.stdin:
|
|
stripped_line = line.strip()
|
|
print(extract_area_code(stripped_line))
|