👨💻 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
@eugenekernan76212 жыл бұрын
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" ?
@DorsCodingSchool2 жыл бұрын
You're correct. Thank you!
@andrejg30865 ай бұрын
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.
@francisvincejaca40772 жыл бұрын
i could've never figured out the pattern without this video. Thank you!
@DorsCodingSchool2 жыл бұрын
Glad we could help!
@federicoelevazo36222 жыл бұрын
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. ^_^
@getstart9811 ай бұрын
Splendid as always!
@athbuys35882 жыл бұрын
thanks so much! the way you go through the regex patterns makes the very easy to follow
@DorsCodingSchool2 жыл бұрын
We are glad to hear that :)
@rohith6255 Жыл бұрын
do you really have to check if the url is inside ?? can't we just match it https... by using caret ^ operator ??
@PurpleDovee5 ай бұрын
no because ^ will mean nothing can be before , but in html files cant be the only tag can it
@luklach Жыл бұрын
you can do def parse in 2 lines instead of 5 :)
@DorsCodingSchool Жыл бұрын
Great 😊
@ertikrajkova27489 ай бұрын
how
@IamMuslimChad11 ай бұрын
Man i was stuuuck for many hours........ I was just doing from the whole
@awesomeadvices5962 Жыл бұрын
super awesome
@manoellopes Жыл бұрын
Salvou ! 👍
@zhrrbh20482 жыл бұрын
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.”
@DorsCodingSchool2 жыл бұрын
if you want you can join our Free Discord Community: www.dorscodingschool.com/discord
@justynyeo45213 ай бұрын
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 Жыл бұрын
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 Жыл бұрын
bro ☠☠☠
@zikobht6618 Жыл бұрын
Bro has beef with Regex
@haseifan11 ай бұрын
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-mu4qu9 ай бұрын
doesnt everyone?@@zikobht6618
@RayhaanKhan-mu4qu9 ай бұрын
great!
@PurpleDovee5 ай бұрын
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()
@muhammadrayyan1475 ай бұрын
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()