forked from miczar1/djfz-24_25
Solve TaskC20
Snooze...
This commit is contained in:
parent
8bb69f7cf5
commit
8b27cc30c1
17
TaskC20/solution.py
Normal file
17
TaskC20/solution.py
Normal file
@ -0,0 +1,17 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
def extract_phone_number(line: str) -> str:
|
||||
# The Pattern:
|
||||
# - Start word-boundary
|
||||
# - An optional leading zero
|
||||
# - Two digits followed by a space
|
||||
# - Then a digit, followed by '-', then three digits, then '-', then three digits
|
||||
p = re.compile(r'\b([0]?\d{2}\s\d-\d{3}-\d{3})\b')
|
||||
m = p.search(line)
|
||||
return m.group(1) if m else "<NONE>"
|
||||
|
||||
if __name__ == "__main__":
|
||||
for line in sys.stdin:
|
||||
stripped_line = line.strip()
|
||||
print(extract_phone_number(stripped_line))
|
6
TaskC20/test.out
Normal file
6
TaskC20/test.out
Normal file
@ -0,0 +1,6 @@
|
||||
00 0-000-000
|
||||
000 0-000-000
|
||||
<NONE>
|
||||
061 5-555-553
|
||||
61 5-555-553
|
||||
<NONE>
|
Loading…
Reference in New Issue
Block a user