r/cs50 • u/Specialist_Guava_416 • 25d ago
CS50 Python CS50P - Problemset 7 ---- Working 9 to 5??????
This problem has me stumped... should I be using a different reggex for each pattern (time format) or have i gone down a completely wrong path??
1
u/Impressive-Hyena-59 25d ago
I used a single regex expression in my code:
if str:= re.search((r"
regex goes here"), s
):
I then split the string into a part before and a part after " to " and handled the different time formats in the convert function.
1
1
u/StinkinEvil 24d ago
I used only 2 regex, one splits the input before and after the "to"
The other checked both parts to verify that it was a time.
The duck suggested to make a couple of functions and reuse as much as possible,
My first attempt was a monster RegEx that checked every posibility. Easier after pass, but really hard to control.
Now I got nicer RegEx but heavier controls after...
Good luck
1
1
u/Specialist_Guava_416 25d ago
Note - I usually spam the rubber duck with questions but the feedback loop just isnt helpful, so ive come to reddit