PROBLEM SET 7: WATCH ON YOUTUBE | SOLUTION (CS50 PYTHON)

  Рет қаралды 14,137

Dors Coding School

Dors Coding School

Күн бұрын

Пікірлер: 46
@DorsCodingSchool
@DorsCodingSchool Жыл бұрын
👨‍💻 Learn How to Code with Private Classes - www.dorscodingschool.com/coachingplans ❓Having a hard time with CS50, FreeCodeCamp or Odin Project? Practice with our exclusive free coding platform: www.codingdors.com/ 🎯 Are You A Coding Expert? Take Our Free Quiz and Find Out - www.dorscodingschool.com/quiz
@eugenekernan7621
@eugenekernan7621 2 жыл бұрын
You have placed an asterisk after the "s" in the pattern for the URL protocol. This would match 0 or more "s" s after "http". Should you not put a "?" after "s" in order to indicate either no "s" or 1 "s" ?
@DorsCodingSchool
@DorsCodingSchool 2 жыл бұрын
You're correct. Thank you!
@andrejg3086
@andrejg3086 5 ай бұрын
Good video. You don't need to use a backslash "\" to escape a slash "/", because a slash is not a special character in regular expressions in Python.
@francisvincejaca4077
@francisvincejaca4077 2 жыл бұрын
i could've never figured out the pattern without this video. Thank you!
@DorsCodingSchool
@DorsCodingSchool 2 жыл бұрын
Glad we could help!
@federicoelevazo3622
@federicoelevazo3622 2 жыл бұрын
I got terrible migraine trying to figure out the regex solution for this. If I opt using regex, the solution is easy. But since I wanna learn more with regex, I surrender and end up watching this vid to learn the proper way of doing it. ^_^
@getstart98
@getstart98 11 ай бұрын
Splendid as always!
@athbuys3588
@athbuys3588 2 жыл бұрын
thanks so much! the way you go through the regex patterns makes the very easy to follow
@DorsCodingSchool
@DorsCodingSchool 2 жыл бұрын
We are glad to hear that :)
@rohith6255
@rohith6255 Жыл бұрын
do you really have to check if the url is inside ?? can't we just match it https... by using caret ^ operator ??
@PurpleDovee
@PurpleDovee 5 ай бұрын
no because ^ will mean nothing can be before , but in html files cant be the only tag can it
@luklach
@luklach Жыл бұрын
you can do def parse in 2 lines instead of 5 :)
@DorsCodingSchool
@DorsCodingSchool Жыл бұрын
Great 😊
@ertikrajkova2748
@ertikrajkova2748 9 ай бұрын
how
@IamMuslimChad
@IamMuslimChad 11 ай бұрын
Man i was stuuuck for many hours........ I was just doing from the whole
@awesomeadvices5962
@awesomeadvices5962 Жыл бұрын
super awesome
@manoellopes
@manoellopes Жыл бұрын
Salvou ! 👍
@zhrrbh2048
@zhrrbh2048 2 жыл бұрын
r'' it must be r'' bc Adding ? immediately after either, a la *? or +?, “makes it perform the match in non-greedy or minimal fashion; as few characters as possible will be matched.”
@DorsCodingSchool
@DorsCodingSchool 2 жыл бұрын
if you want you can join our Free Discord Community: www.dorscodingschool.com/discord
@justynyeo4521
@justynyeo4521 3 ай бұрын
found the easiest way to do it that aligns more with the lecture: import re import sys def main(): print(parse(input("HTML: "))) def parse(s): if match := re.search(r'src="(?:https?://(?:www\.)?youtube\.com/embed/([a-zA-Z0-9]+))"', s): return(f"youtu.be/{match.group(1)}") else: return None if __name__ == "__main__": main()
@rideaux8533
@rideaux8533 Жыл бұрын
i found the most idiotic way to solve this problem and it worked i think i could do anything to avoid using regex def main(): print(parse(input("HTML: "))) def parse(s): try: line = s.find('src="') line = line + 5 qpos = s.find('"', line) final = s[line:qpos] rev1 = final.replace('embed/','') rev2 = rev1.replace('be','') rev3 = rev2.replace('.com','.be') rev4 = rev3.replace('www.','') rev5 = rev4.replace('http','https') rev6 = rev5.replace('httpss','https') if not 'yout' in rev6: return None elif not 'https' in rev6: return None return rev6 except: return None if __name__ == "__main__": main()
@rutesh1902
@rutesh1902 Жыл бұрын
bro ☠☠☠
@zikobht6618
@zikobht6618 Жыл бұрын
Bro has beef with Regex
@haseifan
@haseifan 11 ай бұрын
Thanks for this, for some reason the stupid bot fails my solution... gives me: expected output: kzbin.info/www/bejne/rqepi52larWafZI actual output: kzbin.info/www/bejne/rqepi52larWafZI... its broken😅
@RayhaanKhan-mu4qu
@RayhaanKhan-mu4qu 9 ай бұрын
doesnt everyone?@@zikobht6618
@RayhaanKhan-mu4qu
@RayhaanKhan-mu4qu 9 ай бұрын
great!
@PurpleDovee
@PurpleDovee 5 ай бұрын
import re import sys def main(): print(parse(input("HTML: "))) def parse(s): match = re.search(r'src="(?:https?://(?:www\.)?)?youtube\.com/embed/(?P[^"]+)"', s) if match: vid_id = match.group("vid_id") return f"youtu.be/{vid_id}" return None if __name__ == "__main__": main()
@muhammadrayyan147
@muhammadrayyan147 5 ай бұрын
This is my code, I went with this approach. It works perfectly but could you please tell me if this is the write way or are there any bugs in this import re import sys def main(): print(parse(input("HTML: "))) def parse(s): if gained := re.search(r"^.+(kzbin.info)(\w+)\".+$", s): YT_ID=gained.group(1) + gained.group(2) YT_ID=YT_ID.replace("www.","").replace("be.com/embed",".be") return YT_ID if __name__ == "__main__": main()
PROBLEM SET 7: RESPONSE VALIDATION | SOLUTION (CS50 PYTHON)
5:29
Dors Coding School
Рет қаралды 7 М.
PROBLEM SET 7: WORKING 9 TO 5 | SOLUTION (CS50 PYTHON)
24:49
Dors Coding School
Рет қаралды 24 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
PROBLEM SET 7: REGULAR, UM, EXPRESSIONS | SOLUTION (CS50 PYTHON)
11:58
Dors Coding School
Рет қаралды 10 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 339 М.
PROBLEM SET 7: NUMB3RS | SOLUTION (CS50 PYTHON)
16:11
Dors Coding School
Рет қаралды 17 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 906 М.
PROBLEM SET 8: COOKIE JAR | SOLUTION (CS50 PYTHON)
20:41
Dors Coding School
Рет қаралды 22 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН