CS50P - Lecture 7 - Regular Expressions

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 183

  • @kingofcastlechaos
    @kingofcastlechaos Рік тому +81

    I have often used the phrase "Let me propose....." during large gatherings and it is like a dog whistle for finding my CS50 peeps in a crowd. Their heads whip around and our eyes connect and we share a smile. Thank you Professor Malin for all you have done for us. Your contribution to the world will never be fully quantified.

    • @crysre
      @crysre 5 місяців тому

      *Malan

    • @josket821
      @josket821 5 місяців тому +3

      ​@@crysre you had to ruin

    • @crysre
      @crysre 5 місяців тому +1

      @@josket821 haha, it's the way life works man

    • @toke7342
      @toke7342 2 місяці тому

      *Malan

  • @xavier2586
    @xavier2586 2 роки тому +262

    I said it before and I'll say it again, I'll never forget this man in my whole lifetime.

    • @davidjmalan
      @davidjmalan 2 роки тому +76

      Thank you, Xavier!

    • @chorakdoon6658
      @chorakdoon6658 11 місяців тому +17

      Why does this sound sweet and threatening at the same time 😂

  • @seraphim9219
    @seraphim9219 2 роки тому +402

    david i'm gonna need to put a backslash before you, bc you're a special character to me ;)

  • @Caravanseraii
    @Caravanseraii 5 місяців тому +13

    I like the professor's way of speaking.Very articulate and precise.

  • @Drop_The_Mic
    @Drop_The_Mic 2 роки тому +128

    David J. Malan, Sir you are a great role model for all lecturers. you put a lot of effort into teaching and making the class fun. I hope all lecturers are like you.

    • @davidjmalan
      @davidjmalan 2 роки тому +38

      Thanks for the kind words!

    • @bcak611
      @bcak611 2 роки тому +1

      He is a lecturer, from Harvard! xD

    • @williamenur3404
      @williamenur3404 2 роки тому +2

      @@davidjmalan You are the best teacher i’ve ever seen

    • @its_me_tabs
      @its_me_tabs Рік тому +2

      @Drop_The_Mic if you are a lecturer and you put in the work to improve your game as a lecturer, I want to specifically say hats off to you too for that! As a student, I have witnessed lecturers who are too proud to learn and yet they are not doing so well, and thus never improve. They will continue to mess up below-average students` careers and watch above-average students excel and celebrate their successes and credit them to themselves.

  • @Terrysophia-lg3oe
    @Terrysophia-lg3oe Рік тому +48

    I never thought regular expressions could be fun until I watched this lecture. Thank so much!

  • @diegomaterano6352
    @diegomaterano6352 11 місяців тому +11

    omg, I can't belive this has been my favorite lecture, the most fun, entertaining, and easy to understand. I mean it's regex we are talking about, it could have been a completely pain otherwise. Thank you so much David, and the cs50 team for giving us this opporunity to learn from the best

  • @oooogaabooogaa
    @oooogaabooogaa 9 місяців тому +2

    And here I was thinking I would never grasp regex. Prof. Malan is a one in a million teacher, a true master, an artist at the top of his craft. Many thanks to the whole CS50 crew.

  • @VanishMe
    @VanishMe 8 місяців тому +6

    I looked into the notes a few times before starting this lecture and i was so confused and was dreading having to learn all of this honestly and was getting desperate and thought i should just quit.
    But David explained it so well, everything just clicked and it all just made sense. Incredible teaching skills. Thank you so much to the entire teaching staff at CS50 and especially David.
    Came into CS50P with no prior coding or CS experience at all and it is such a good feeling seeing the progress i've made so far. What an incredible journey.

    • @VinnieG-
      @VinnieG- 8 місяців тому

      that official regular expression google would use for matching email adresses made me poop my pants

  • @davngo
    @davngo 2 роки тому +21

    The best explanation of regex that I've ever seen.

  • @liyangau
    @liyangau 2 роки тому +31

    Hands down the best Regex video I've ever watched. Thank you

  • @sergey_zatsepin
    @sergey_zatsepin Рік тому +7

    34:43 works because of last point and $ in regex accordingly, but there is no necessety in ^, it has no effect

    • @mezlatanis
      @mezlatanis 11 місяців тому

      Thanks was confused on it

  • @bruce2877
    @bruce2877 7 місяців тому +6

    1:38:58, Seeing David laugh is a joy

  • @drutsuk3598
    @drutsuk3598 3 місяці тому +3

    i am a collage student from VIT , not so great collage but by attending your cource make me feel like i am at havard , you make all concepts so easy to grasp, i really want to come at this year cs50 fest but due to financial limitations i can't , but one day i will really like to meet you in person

  • @Qwonk
    @Qwonk 2 роки тому +28

    Take a shot every time David says "Let me propose"

  • @sushmasingh9040
    @sushmasingh9040 4 місяці тому +1

    best cs50p lecture so far

  • @adileru
    @adileru 2 роки тому +5

    David Malan is one in a billion!
    Regards from Romania

  • @evachen8623
    @evachen8623 Рік тому +3

    This class is way harder than I thought before, but thankfully there's David Malan answering all the questions right after they pop up in my brain even though I couldn't even ask.

  • @tsmartins
    @tsmartins 4 місяці тому +2

    1:38:50 reminder to come back and watch my favourite Professor "break out of character"

  • @madefromjames
    @madefromjames Рік тому +2

    I'm just so happy to learn Python the easy way with David.

  • @sayori3939
    @sayori3939 2 роки тому +16

    Hehe i love how David can understand what some foreigners with heavy accent says and hear people basically whispering (cs50x) that's why i could never be a teacher, i would make the students feel uncomfortable asking"what, repeat, what did you say, huh" ;3

    • @sergey_zatsepin
      @sergey_zatsepin Рік тому

      Don't be weird, it's totally normal to ask, and David does it on pure CS50 course lectures. And moreover, it's the student's problem if teacher doesn't understand/hear his question.

    • @sayori3939
      @sayori3939 Рік тому +3

      @@sergey_zatsepin It's not just him though ._. all my teachers in school had some weird hearing superpower

    • @MattRose30000
      @MattRose30000 Рік тому +12

      @@sayori3939 at some point you already know 99% of the questions the students will ask. so you just need to hear certain keywords to figure out what the question is.

    • @pulkitkrishna8809
      @pulkitkrishna8809 Рік тому +3

      @@MattRose30000 Exactly. In CS50P, you can see David making some wrong guesses to what the question is.

  • @mariyayurchenko2790
    @mariyayurchenko2790 2 місяці тому

    Bravo, you guide your students through even relatively tricky topic with grace.

  • @muzammilomarzoy6616
    @muzammilomarzoy6616 Рік тому +2

    00:38:58 - Sets of Characters
    00:49:18 - Character Classes
    01:20:40 - Capturing Groups
    02:00:30 Question

  • @yashgoyal905
    @yashgoyal905 2 роки тому +8

    Thanks for all of this and your great efforts in teaching. Can't see it live but will definitely see it tonight

  • @njmanga617
    @njmanga617 2 роки тому +8

    Love the lectures even if I have seen it before never gets boring

  • @priteshugrankar6815
    @priteshugrankar6815 11 місяців тому

    Man, this is like having Joe Satriani as your guitar instructor!! Amazing stuff!! Thank you sir!!

  • @relaxmore444
    @relaxmore444 2 роки тому +12

    Thank you for doing this David! It made me understand regex better.

    • @sayori3939
      @sayori3939 2 роки тому +1

      But that's not fair, you have "Re" and "x" in your name! '0'

  • @yqhanliving
    @yqhanliving 11 місяців тому +1

    So good. Thank you CS50 team!

  • @dakoderii4221
    @dakoderii4221 2 роки тому +34

    Lectures 1-6 and 8-9: 🤔😀
    Lecture 7: 🤯😩

    • @BT-te9vx
      @BT-te9vx 2 роки тому +2

      so true :(

    • @RayhaanKhan-mu4qu
      @RayhaanKhan-mu4qu 9 місяців тому +1

      trueeee

    • @anthronox4992
      @anthronox4992 5 місяців тому

      It's not your fault bro. Nobody blames you. You can be free now.

    • @anushkaaaa
      @anushkaaaa 4 місяці тому

      this is so true, this lec is definitely harder than the previous ones

  • @VinnieG-
    @VinnieG- 8 місяців тому

    I love how David tries to break the code, and still made it work somehow 1:39:00

  • @monicagalloriofrio9551
    @monicagalloriofrio9551 2 роки тому +2

    muy genial Sr... Inspiration for teachers world wide...

  • @zawarudu9206
    @zawarudu9206 2 роки тому

    This one is the best so far and the best lecture I have seen teaching re so far

  • @mritunjoypaul10
    @mritunjoypaul10 8 місяців тому

    Hands down best regular expressions lecture

  • @mostafamarwanmostafa9975
    @mostafamarwanmostafa9975 Рік тому +2

    Thank you sir, it helped me in my NLP course!

  • @kebincui
    @kebincui 3 місяці тому

    the best one in a million❤, thanks David

  • @Neojs565
    @Neojs565 Рік тому +2

    I watched till the end and even practiced; this is the first time I understood regex...

  • @williamenur3404
    @williamenur3404 2 роки тому +5

    My Progress is very nice thank you David!

    • @mrsan4856
      @mrsan4856 2 роки тому

      hii r u at week 7 ?

    • @williamenur3404
      @williamenur3404 2 роки тому

      @@mrsan4856 I’ve already finished it,and it’s my second time I’m taking CS50P😃

    • @intothepc
      @intothepc Рік тому

      What why?@@williamenur3404

    • @abdurrafay1747
      @abdurrafay1747 4 місяці тому

      @@williamenur3404 why second time ?

  • @maggotdeath12
    @maggotdeath12 Рік тому +1

    Благодаря ти, брат

  • @ManagingSaging
    @ManagingSaging 11 місяців тому

    Thank you Sir David for super enjoyable lecture!!

  • @daughterofanartist7223
    @daughterofanartist7223 5 місяців тому +1

    well explained ! Jazak'Allah hu khair brother. God bless you

  • @mahipalmahato7648
    @mahipalmahato7648 2 роки тому +1

    re start at 1:00:51

  • @Nguyen_An369
    @Nguyen_An369 Рік тому

    Thank Mr.David J. Malan so much

  • @vishalverma4838
    @vishalverma4838 Рік тому

    Easy to understand and practice, great presentation.

  • @baris5081
    @baris5081 2 роки тому +2

    great teacher

  • @mattryan6832
    @mattryan6832 9 місяців тому +3

    start: farmer grows the carrot ^, end: farmer profits $

  • @sayori3939
    @sayori3939 2 роки тому +1

    Around 1:20:00 i know the main point of the video is to show RE but wouldn't it be safer if you just split the string with , (without space) then stripped the white spaces in the variables?

    • @sayori3939
      @sayori3939 2 роки тому +1

      That match group is incredible :0

  • @yagmurkalyoncu2681
    @yagmurkalyoncu2681 28 днів тому

    I love this man

  • @donermannali2701
    @donermannali2701 Рік тому

    man I love this man

  • @VinayakGNair
    @VinayakGNair 2 роки тому +2

    Very tricky lecture. Regular expression is little difficult to get hold of.

  • @adam_belounis.
    @adam_belounis. 9 місяців тому

    Enjoyable , educational

  • @techninja2940
    @techninja2940 2 роки тому +1

    Brilliant 👨‍🏫

  • @Jgift_9x
    @Jgift_9x 2 роки тому +6

    keep CS50 on the Lecture Hall classroom < please >. You are not just another Online class.

    • @sayori3939
      @sayori3939 2 роки тому +1

      Is that lecture hall the place that he teaches introduction to computer science, if so, yeah i miss that place too

  • @manuellayburr382
    @manuellayburr382 Рік тому

    Mystery at 48:30 - In the code at line 5 in the regular expression, we incorrectly have ".eu$" instead of ".edu$". Yet the program still validates the email address! Why?

    • @samfisher8583
      @samfisher8583 Рік тому

      I went down to the comments to find an answer too? You know what's the problem?

    • @princewaesen154
      @princewaesen154 Рік тому

      Huh?

    • @anthronox4992
      @anthronox4992 5 місяців тому

      We have ".edu$". You must be mistaken.

  • @AdamRakhamim
    @AdamRakhamim Рік тому

    bookmark 49:00

  • @ivanpiskovic4151
    @ivanpiskovic4151 5 місяців тому

    Is the diagram in this video at 21:40 depicting a moore machine,

  • @nicomal
    @nicomal Рік тому +1

    Complement this class with the Socratica video on regular expressions.

  • @intxcated
    @intxcated Рік тому +1

    2:03:03 can we just use (\w+) instead of [a-z0-9_]+ ?

    • @l4nzel0d
      @l4nzel0d Рік тому

      I think David didn't use it because that would allow upper case letters in the user name

    • @intxcated
      @intxcated Рік тому

      @@l4nzel0dOh I thought it didn't matter since we were using re.IGNORECASE

  • @adam_belounis.
    @adam_belounis. 8 місяців тому

    David is the best

  • @vatsoffice
    @vatsoffice 10 місяців тому

    in the capturing groups part, when you wrote the final group for matching, will it work for that David Malan Jr?

  • @0765
    @0765 3 місяці тому

    Somebody please explain why it is greedy with the '?' but not '*" at 1:29:11? And when I omit the comma before the whitespace, it is not greedy anymore, even thought keeping the '?'

    • @KimPotterz
      @KimPotterz 17 днів тому

      WITH Question Mark:
      REGEX = ^(.+), ?(.+)$
      Question Mark means zero or one (space).
      so, it will make only one space as optional separator,
      and it will actually include the rest of the spaces in the second group.
      WITH Star:
      REGEX = ^ (.+), *(.+)$
      Star means zero or more (spaces).
      It will make the whole spaces in between 2 groups as optional separator.
      Conclusion:
      TEXT collected from each group with Question Mark Regex:
      input = "Kim, Potterz" *5 spaces
      (Kim) ( Potterz) *4 spaces were included because the first one used by ? to separate the two groups.
      Make comma and the first space as separator, and the rest of the spaces included in the second group.
      TEXT collected from each group with Star Regex:
      input = "Kim, Potterz"
      (Kim) (Potterz)
      Make comma and the whole spaces as separator, and include whatever text comes after comma and spaces in the second group.
      use this to see the output:
      print(f"First Group: ({matches.group(1)}), Second Group: ({matches.group(2)})").
      I don't really get your second question.
      @kimpotterz

  • @nowak93
    @nowak93 2 роки тому

    this tickles my brain

  • @شیداعسکری-ل5ل
    @شیداعسکری-ل5ل 9 місяців тому

    Thank you❤

  • @TrismegistusH
    @TrismegistusH Рік тому

    1:28:52 he says that "?" is 0 or more but the notes say 0 or 1?

    • @pabloa.2586
      @pabloa.2586 Рік тому

      "?" is 0 or 1. "Malan, David" worked because the ".+" tolerates and captures the big chunk of whitespaces

    • @TrismegistusH
      @TrismegistusH Рік тому

      yes i realized he misspoke@@pabloa.2586

  • @oyekanmibamidele6196
    @oyekanmibamidele6196 2 роки тому

    What a great tutorial!

  • @Mayday-wy2yp
    @Mayday-wy2yp Місяць тому

    Are you ready to see what exactly browsers use for that??

  • @Mecutiesweetie
    @Mecutiesweetie 2 роки тому

    It's so helpful, thank you ! But why is there no word about re.compile function? is it not so vital in regex?

  • @williamenur3404
    @williamenur3404 2 роки тому

    Course is Best

  • @denisc.1282
    @denisc.1282 2 роки тому

    Can there be conditionals? Let’s say I don’t want letter o be right next to digit 0 when it appears for the first time in the string

  • @Navdeep-nq9ui
    @Navdeep-nq9ui Рік тому

    thank you sir

  • @SoyedReyazulIslamReyad
    @SoyedReyazulIslamReyad 3 місяці тому

    So you are telling me that I could just do it to make that vanity plate thing?

  • @appleapple1763
    @appleapple1763 2 роки тому

    30:00 what does it mean?

  • @g.d..
    @g.d.. 2 роки тому +3

    very good lecture, thank you very much, is there a lecture planned for Lists and Dictionary presently?

  • @Vicktor69
    @Vicktor69 2 роки тому

    Thank you!

  • @amine63404
    @amine63404 Рік тому

    01:30:00

  • @thyagolopes3020
    @thyagolopes3020 2 місяці тому

    Week 7... so close 🤞

  • @besegawG
    @besegawG 5 днів тому

    Might have to watch this a few times the syntax is ridiculous to grasp

  • @sayori3939
    @sayori3939 2 роки тому +2

    "working 9 to 5" pset made me feel like i had worked from 9 to 5 and made me feel upset :(
    66 lines of pure hackish code but hey at least i learned you can actually name the groups in the search like (?P) and then m.group('name') that's pretty cool :3

  • @darkooo94
    @darkooo94 2 роки тому +4

    What happens at 48:25 when David pastes the set of characters? The suffix ".edu" turns to ".eu" but the code works as it didn't happen.

    • @uniatrix
      @uniatrix Рік тому

      I also wanted to know that lol

  • @yessir2649
    @yessir2649 Рік тому

    Thank u

  • @fionalazarus2166
    @fionalazarus2166 Рік тому +1

    You could teach a monkey how to code, literally! Best explanation👏

  • @ArbaazBeg
    @ArbaazBeg Рік тому

    can you use dark mordern theme?

  • @winstonbarendse3647
    @winstonbarendse3647 2 роки тому

    2:01:50

  • @8trakau
    @8trakau Рік тому

    DJM you will always be "Space David" to me now :)

  • @Raiyan68
    @Raiyan68 Рік тому

    1:12:13

  • @trunghainguyen9872
    @trunghainguyen9872 2 роки тому +3

    1:38:55 funny :)

  • @aa_yu_s_h
    @aa_yu_s_h Рік тому

    I have a great feeling to see you hacking !
    And breaching. 🔥

  • @pakchiechan4867
    @pakchiechan4867 Рік тому

    59:51

  • @munim6940
    @munim6940 Рік тому

    The shout at 56:35 xD

  • @6srer
    @6srer 2 роки тому

    Hello from Kenya

    • @danielwari2760
      @danielwari2760 2 роки тому

      Wagwan Solomon ,
      Also from Kenya ,
      Have you taken coding and programming classes from Kenya ?
      Looking to learning python to start my Data science or analyst course .

  • @mahmutpekkara
    @mahmutpekkara Місяць тому

    Remember that sometimes you open up a some obscure file and Microsoft WordPad shows you a weird bunch of characters in urls..?

  • @firefuegomakes
    @firefuegomakes Рік тому

    Lesson of the lesson, do not be generous

  • @isitool8
    @isitool8 Рік тому +2

    My head hurts

  • @nehanthv4238
    @nehanthv4238 Рік тому

    47:30

  • @fishnotfosh
    @fishnotfosh Рік тому

    @davidjmalan on the watch on youtube homework assignment...why did you put the rickroll link...
    Days since rickrolled reset from 3 years to 0 days. God damn it.

  • @ufallo
    @ufallo Рік тому

    33:45 "Expressions" Carrot on a string / /Dollar at the end of a string lolol

  • @michaelcoffey3563
    @michaelcoffey3563 Рік тому

    I have the exact code copied, but if I put "my username is" at the start of the user input it doesn't work any longer, I thought this is what the caret was supposed to do, can somebody give guidance please?

  • @newadClass
    @newadClass 7 місяців тому

    10:00

  • @xue7444
    @xue7444 2 роки тому

    This is golden

  • @Pr0feBboy
    @Pr0feBboy Рік тому

    While watching the lecture I thought Regex is cool but when I started doing the problem sets for Regex I found out that Regex is a terrible way to handle strings... absolutely cryptic and impossible to learn at first.. It makes me wanna quit studying any type of programming ...

  • @sayori3939
    @sayori3939 2 роки тому

    I had severe problems with last pset problem, PIL docs is so freaking confusing and not straight it presents functions without telling the argument making you read a whole paragraph and it never raised any errors and the file wasn't saving a new file (INCLUDE THAT IF __NAME__ THINGY AT END!!!) Saddly looking for why my code wasn't working i got spoiled by a function from pil that solved the problem :/ and I COULDN'T FIND IT IN THE FREAKING DOCS even though i clearly imported it from PIL