[ { "text": "[Music]", "start": 3.4, "duration": 9.859 }, { "text": "[Music]", "start": 15.28, "duration": 6.869 }, { "text": "all right this is cs50's Introduction to", "start": 24.56, "duration": 4.799 }, { "text": "programming with python my name is David", "start": 27.48, "duration": 3.879 }, { "text": "men and this is our week on regular", "start": 29.359, "duration": 4.641 }, { "text": "Expressions so a regular expression", "start": 31.359, "duration": 4.961 }, { "text": "otherwise known as a Rex is really just", "start": 34.0, "duration": 4.36 }, { "text": "a pattern and indeed it's quite common", "start": 36.32, "duration": 4.12 }, { "text": "in programming to want to use patterns", "start": 38.36, "duration": 4.679 }, { "text": "to match on some kind of data often user", "start": 40.44, "duration": 4.56 }, { "text": "input for instance if the user types in", "start": 43.039, "duration": 4.0 }, { "text": "an email address whether to your program", "start": 45.0, "duration": 4.079 }, { "text": "or a website or an app on your phone you", "start": 47.039, "duration": 3.321 }, { "text": "might ideally want to be able to", "start": 49.079, "duration": 3.241 }, { "text": "validate that they did indeed type in an", "start": 50.36, "duration": 3.28 }, { "text": "email address and not something", "start": 52.32, "duration": 3.36 }, { "text": "completely different so using regular", "start": 53.64, "duration": 3.399 }, { "text": "Expressions we're going to have the new", "start": 55.68, "duration": 3.8 }, { "text": "found capability to Define patterns in", "start": 57.039, "duration": 4.881 }, { "text": "our code to compare them against data", "start": 59.48, "duration": 4.039 }, { "text": "that we're receiving from someone else", "start": 61.92, "duration": 3.44 }, { "text": "whether it's just a validated or heck", "start": 63.519, "duration": 3.441 }, { "text": "even if we want to clean up a whole lot", "start": 65.36, "duration": 3.36 }, { "text": "of data that itself might be messy", "start": 66.96, "duration": 4.44 }, { "text": "because it too came from us humans", "start": 68.72, "duration": 4.48 }, { "text": "before though we use these regular", "start": 71.4, "duration": 4.399 }, { "text": "Expressions let me propose that we solve", "start": 73.2, "duration": 5.84 }, { "text": "a few problems using just some simpler", "start": 75.799, "duration": 5.041 }, { "text": "syntax and see what kind of limitations", "start": 79.04, "duration": 4.079 }, { "text": "we run up against let me propose that I", "start": 80.84, "duration": 4.599 }, { "text": "open up vs code here and let me create a", "start": 83.119, "duration": 4.481 }, { "text": "file called validate dopy the goal at", "start": 85.439, "duration": 3.801 }, { "text": "hand being to validate how about just", "start": 87.6, "duration": 3.519 }, { "text": "that a US users's email address they've", "start": 89.24, "duration": 3.32 }, { "text": "come to your app they've come to your", "start": 91.119, "duration": 3.04 }, { "text": "website they type in their email address", "start": 92.56, "duration": 4.04 }, { "text": "and we want to say yes or no this email", "start": 94.159, "duration": 5.0 }, { "text": "address looks valid all right let me go", "start": 96.6, "duration": 5.92 }, { "text": "ahead and type code of validate dopy to", "start": 99.159, "duration": 5.481 }, { "text": "create a new tab here and then within", "start": 102.52, "duration": 3.68 }, { "text": "this tab let me go ahead and start", "start": 104.64, "duration": 4.04 }, { "text": "writing some code how about that keeps", "start": 106.2, "duration": 4.44 }, { "text": "things simple initially first let me go", "start": 108.68, "duration": 3.64 }, { "text": "ahead and prompt the user for their", "start": 110.64, "duration": 3.839 }, { "text": "email address and I'll store the return", "start": 112.32, "duration": 4.56 }, { "text": "value of input in a variable called", "start": 114.479, "duration": 5.521 }, { "text": "email asking them what's your email", "start": 116.88, "duration": 4.8 }, { "text": "question mark I'm going to go ahead and", "start": 120.0, "duration": 3.28 }, { "text": "preemptively at least clean up the", "start": 121.68, "duration": 3.719 }, { "text": "user's input a little bit by minimally", "start": 123.28, "duration": 4.839 }, { "text": "just calling strip at the end of my call", "start": 125.399, "duration": 5.121 }, { "text": "to input because recall that input", "start": 128.119, "duration": 5.401 }, { "text": "returns a string or a stir stirs come", "start": 130.52, "duration": 5.04 }, { "text": "with some built-in methods or functions", "start": 133.52, "duration": 3.84 }, { "text": "one of which is strip which has the", "start": 135.56, "duration": 3.399 }, { "text": "effect of stripping off any leading", "start": 137.36, "duration": 3.959 }, { "text": "white space to the left or any trailing", "start": 138.959, "duration": 4.081 }, { "text": "white space to the right so that's just", "start": 141.319, "duration": 3.64 }, { "text": "going to go ahead and at least avoid the", "start": 143.04, "duration": 3.72 }, { "text": "human having accidentally typed in a", "start": 144.959, "duration": 3.121 }, { "text": "space character we're going to throw it", "start": 146.76, "duration": 3.72 }, { "text": "away just in case now I'm going to do", "start": 148.08, "duration": 5.84 }, { "text": "something simple for a user's input to", "start": 150.48, "duration": 5.36 }, { "text": "be an email address I think we can all", "start": 153.92, "duration": 3.679 }, { "text": "agree that it's got to minimally have an", "start": 155.84, "duration": 3.759 }, { "text": "at sign somewhere in it so let's start", "start": 157.599, "duration": 3.72 }, { "text": "simple if the user has typed in", "start": 159.599, "duration": 3.92 }, { "text": "something with an at sign let's very", "start": 161.319, "duration": 4.441 }, { "text": "generously just say Okay valid looks", "start": 163.519, "duration": 3.8 }, { "text": "like an email address and if we're", "start": 165.76, "duration": 4.04 }, { "text": "missing that at sign let's say invalid", "start": 167.319, "duration": 4.081 }, { "text": "because clearly it's not an email", "start": 169.8, "duration": 2.92 }, { "text": "address it's not going to be the best", "start": 171.4, "duration": 2.919 }, { "text": "version of my code yet but we'll start", "start": 172.72, "duration": 3.68 }, { "text": "simple so I'm going to ask the question", "start": 174.319, "duration": 5.2 }, { "text": "if there is an at symbol in the user's", "start": 176.4, "duration": 5.119 }, { "text": "email email address go ahead and print", "start": 179.519, "duration": 4.08 }, { "text": "out for instance quote unquote valid", "start": 181.519, "duration": 3.961 }, { "text": "else if there's not now I'm pretty", "start": 183.599, "duration": 3.761 }, { "text": "confident that the email address is in", "start": 185.48, "duration": 5.24 }, { "text": "fact invalid now what is this code doing", "start": 187.36, "duration": 6.84 }, { "text": "well if at sign in email is a pythonic", "start": 190.72, "duration": 5.519 }, { "text": "way of asking is this string quote", "start": 194.2, "duration": 5.88 }, { "text": "unquote at in this other string email no", "start": 196.239, "duration": 5.321 }, { "text": "matter where it is at the beginning the", "start": 200.08, "duration": 2.719 }, { "text": "middle of the end it's going to", "start": 201.56, "duration": 3.08 }, { "text": "automatically search through the entire", "start": 202.799, "duration": 3.921 }, { "text": "string for you automatically I could do", "start": 204.64, "duration": 3.56 }, { "text": "this more verbosely and I could use a", "start": 206.72, "duration": 3.56 }, { "text": "for Loop or a while loop and look at", "start": 208.2, "duration": 3.92 }, { "text": "every character in The user's email", "start": 210.28, "duration": 3.679 }, { "text": "address looking to see if it's an at", "start": 212.12, "duration": 3.16 }, { "text": "sign but this is one of the things", "start": 213.959, "duration": 3.161 }, { "text": "that's nice about python you can do more", "start": 215.28, "duration": 4.599 }, { "text": "with less so just by saying if at quote", "start": 217.12, "duration": 4.88 }, { "text": "unquote in email we're achieving that", "start": 219.879, "duration": 3.801 }, { "text": "same result we're going to get back true", "start": 222.0, "duration": 4.12 }, { "text": "if it's somewhere in there thus valid or", "start": 223.68, "duration": 4.919 }, { "text": "false if it is not well let me go ahead", "start": 226.12, "duration": 4.479 }, { "text": "now and run this program in my terminal", "start": 228.599, "duration": 4.64 }, { "text": "window with python of validate dopy and", "start": 230.599, "duration": 3.64 }, { "text": "I'm going to go ahead and give it my", "start": 233.239, "duration": 4.441 }, { "text": "email address mailen harvard.edu enter", "start": 234.239, "duration": 5.241 }, { "text": "and indeed it's valid looks valid is", "start": 237.68, "duration": 2.68 }, { "text": "valid", "start": 239.48, "duration": 2.64 }, { "text": "but of course this program is", "start": 240.36, "duration": 4.56 }, { "text": "technically broken it's buggy what would", "start": 242.12, "duration": 5.039 }, { "text": "be an example input if someone might", "start": 244.92, "duration": 4.319 }, { "text": "like to volunteer an answer here that", "start": 247.159, "duration": 4.16 }, { "text": "would be considered valid but you and I", "start": 249.239, "duration": 4.64 }, { "text": "know it really isn't valid yeah thank", "start": 251.319, "duration": 4.601 }, { "text": "you uh well pleas to you can type just", "start": 253.879, "duration": 4.88 }, { "text": "to science science and that's it and it", "start": 255.92, "duration": 5.8 }, { "text": "still be valid still be valid according", "start": 258.759, "duration": 5.841 }, { "text": "to your program but the same exactly", "start": 261.72, "duration": 5.199 }, { "text": "we've set a very low bar here in fact if", "start": 264.6, "duration": 4.76 }, { "text": "I go ahead and rerun python of validate", "start": 266.919, "duration": 4.201 }, { "text": "and I'll just type in one add sign", "start": 269.36, "duration": 4.2 }, { "text": "that's it no username no domain name", "start": 271.12, "duration": 3.88 }, { "text": "this doesn't really look like an email", "start": 273.56, "duration": 3.72 }, { "text": "address but unfortunately my code thinks", "start": 275.0, "duration": 3.72 }, { "text": "it in fact is because it's obviously", "start": 277.28, "duration": 3.759 }, { "text": "just looking for an at sign alone well", "start": 278.72, "duration": 4.319 }, { "text": "how could we improve this well minimally", "start": 281.039, "duration": 4.641 }, { "text": "an email address I I think tends to have", "start": 283.039, "duration": 3.641 }, { "text": "though this is not actually a", "start": 285.68, "duration": 3.2 }, { "text": "requirement tends to have an at sign and", "start": 286.68, "duration": 4.239 }, { "text": "a single dot at least maybe somewhere in", "start": 288.88, "duration": 5.48 }, { "text": "the domain name so mailen harvard.edu so", "start": 290.919, "duration": 5.081 }, { "text": "let's check for that dot as well though", "start": 294.36, "duration": 3.52 }, { "text": "again strictly speaking doesn't even", "start": 296.0, "duration": 3.84 }, { "text": "have to be that case but I'm going for", "start": 297.88, "duration": 3.4 }, { "text": "my own email address at least for now as", "start": 299.84, "duration": 3.199 }, { "text": "our test case so let me go ahead and", "start": 301.28, "duration": 3.84 }, { "text": "change my code now and say not only if", "start": 303.039, "duration": 6.72 }, { "text": "at is an email but also uh dot is in", "start": 305.12, "duration": 7.0 }, { "text": "email as well so I'm asking now two", "start": 309.759, "duration": 4.921 }, { "text": "questions I have two Boolean Expressions", "start": 312.12, "duration": 5.4 }, { "text": "if at in email and I'm anding them", "start": 314.68, "duration": 5.16 }, { "text": "together logically this is a logical and", "start": 317.52, "duration": 4.32 }, { "text": "so to speak so if it's the case that at", "start": 319.84, "duration": 5.0 }, { "text": "is an email and Dot is an email okay now", "start": 321.84, "duration": 4.88 }, { "text": "I'm going to go ahead and say valid all", "start": 324.84, "duration": 3.6 }, { "text": "right this would still seem to work for", "start": 326.72, "duration": 3.44 }, { "text": "my email address let me go ahead and run", "start": 328.44, "duration": 5.44 }, { "text": "python of validate dopy maen harbor. edu", "start": 330.16, "duration": 5.72 }, { "text": "enter and that of course is valid as", "start": 333.88, "duration": 4.36 }, { "text": "expected but here too we can be a little", "start": 335.88, "duration": 3.92 }, { "text": "adversarial and type in something", "start": 338.24, "duration": 3.6 }, { "text": "nonsensical like at Dot and", "start": 339.8, "duration": 3.839 }, { "text": "unfortunately that too is going to be", "start": 341.84, "duration": 3.919 }, { "text": "mistaken as valid even though there's", "start": 343.639, "duration": 4.241 }, { "text": "still no username domain name or", "start": 345.759, "duration": 3.601 }, { "text": "anything like that so I think we need to", "start": 347.88, "duration": 4.599 }, { "text": "be a little more methodical here in fact", "start": 349.36, "duration": 6.76 }, { "text": "notice that if I do this like this uh", "start": 352.479, "duration": 5.84 }, { "text": "the at sign can be anywhere and the dot", "start": 356.12, "duration": 4.4 }, { "text": "can be anywhere but if I assuming the", "start": 358.319, "duration": 3.44 }, { "text": "user is going to have a traditional", "start": 360.52, "duration": 3.76 }, { "text": "domain name like harvard.edu or", "start": 361.759, "duration": 4.921 }, { "text": "gmail.com I really want to look for the", "start": 364.28, "duration": 5.039 }, { "text": "dot in the domain name only not", "start": 366.68, "duration": 5.48 }, { "text": "necessarily just the username so let me", "start": 369.319, "duration": 4.801 }, { "text": "go ahead and do this let me go ahead and", "start": 372.16, "duration": 4.599 }, { "text": "introduce a bit more logic here and", "start": 374.12, "duration": 5.84 }, { "text": "instead do this let me go ahead and do", "start": 376.759, "duration": 4.321 }, { "text": "uh", "start": 379.96, "duration": 4.239 }, { "text": "email.it of quote unquote at sign so", "start": 381.08, "duration": 6.04 }, { "text": "email again is a string or a stir stirs", "start": 384.199, "duration": 5.0 }, { "text": "come with methods not just strip but", "start": 387.12, "duration": 4.16 }, { "text": "also another one called split that as", "start": 389.199, "duration": 4.321 }, { "text": "the name applies will split one stir", "start": 391.28, "duration": 3.96 }, { "text": "into multiple ones if you give it a", "start": 393.52, "duration": 5.92 }, { "text": "character or more to split on so this is", "start": 395.24, "duration": 5.679 }, { "text": "hopefully going to return to me two", "start": 399.44, "duration": 3.199 }, { "text": "parts from a traditional email address", "start": 400.919, "duration": 4.161 }, { "text": "the username and the domain name and it", "start": 402.639, "duration": 4.601 }, { "text": "turns out I can unpack that sequence of", "start": 405.08, "duration": 5.36 }, { "text": "responses by doing this username comma", "start": 407.24, "duration": 6.12 }, { "text": "domain equals this I could store it in a", "start": 410.44, "duration": 5.12 }, { "text": "list or some other structure but if I", "start": 413.36, "duration": 4.16 }, { "text": "already know in advance what kinds of", "start": 415.56, "duration": 3.479 }, { "text": "values I'm expecting a username and", "start": 417.52, "duration": 3.32 }, { "text": "hopefully a domain I'm going to go ahead", "start": 419.039, "duration": 3.201 }, { "text": "and do it like this instead and just", "start": 420.84, "duration": 3.72 }, { "text": "Define two variables at once on one line", "start": 422.24, "duration": 4.04 }, { "text": "of code and now I'm going to be a little", "start": 424.56, "duration": 3.72 }, { "text": "more precise if", "start": 426.28, "duration": 6.24 }, { "text": "username uh uh if username then I'm", "start": 428.28, "duration": 7.12 }, { "text": "going to go ahead and say print valid", "start": 432.52, "duration": 5.32 }, { "text": "else I'm going to go ahead and say print", "start": 435.4, "duration": 4.68 }, { "text": "invalid now this isn't good enough but", "start": 437.84, "duration": 3.84 }, { "text": "I'm at least checking for the presence", "start": 440.08, "duration": 3.119 }, { "text": "of a username now and you might not have", "start": 441.68, "duration": 3.359 }, { "text": "seen this before but if you simply ask a", "start": 443.199, "duration": 4.4 }, { "text": "question like if username and username", "start": 445.039, "duration": 5.521 }, { "text": "is a string well usern if username is", "start": 447.599, "duration": 5.16 }, { "text": "going to give me a true answer if", "start": 450.56, "duration": 4.759 }, { "text": "username is anything except none or", "start": 452.759, "duration": 5.041 }, { "text": "quote unquote nothing so there's a a", "start": 455.319, "duration": 4.921 }, { "text": "truthy value here whereby if username", "start": 457.8, "duration": 4.36 }, { "text": "has at least one character that's going", "start": 460.24, "duration": 3.799 }, { "text": "to be considered true but if username", "start": 462.16, "duration": 4.24 }, { "text": "has no characters it's going to be", "start": 464.039, "duration": 5.44 }, { "text": "considered a false value effectively but", "start": 466.4, "duration": 4.32 }, { "text": "this isn't good enough I don't want to", "start": 469.479, "duration": 2.961 }, { "text": "just check for username I want to also", "start": 470.72, "duration": 4.72 }, { "text": "check that it's the case that dot is in", "start": 472.44, "duration": 5.52 }, { "text": "the domain name as well so notice here", "start": 475.44, "duration": 4.68 }, { "text": "there's a bit of potential confusion", "start": 477.96, "duration": 4.76 }, { "text": "with the English language here I seem to", "start": 480.12, "duration": 5.479 }, { "text": "be saying if username and Dot in domain", "start": 482.72, "duration": 5.039 }, { "text": "as though I'm asking the question if the", "start": 485.599, "duration": 5.481 }, { "text": "username and the dot are in the domain", "start": 487.759, "duration": 4.761 }, { "text": "but that's not what this means these are", "start": 491.08, "duration": 3.559 }, { "text": "two separate Boolean Expressions if", "start": 492.52, "duration": 4.0 }, { "text": "username and", "start": 494.639, "duration": 5.441 }, { "text": "separately if dot in domain and if I", "start": 496.52, "duration": 5.079 }, { "text": "parenthesize this we could make that", "start": 500.08, "duration": 3.6 }, { "text": "even more clear by putting parentheses", "start": 501.599, "duration": 3.88 }, { "text": "there parentheses here so just to be", "start": 503.68, "duration": 3.199 }, { "text": "clear it's really two Boolean", "start": 505.479, "duration": 2.961 }, { "text": "Expressions that we're ending together", "start": 506.879, "duration": 4.16 }, { "text": "not one longer english-like sentence now", "start": 508.44, "duration": 5.36 }, { "text": "if I go ahead and run this python of", "start": 511.039, "duration": 5.601 }, { "text": "validate dopy enter I'll do my own email", "start": 513.8, "duration": 5.0 }, { "text": "address again mailin harvard.edu and", "start": 516.64, "duration": 5.72 }, { "text": "that's valid and it looks like I could", "start": 518.8, "duration": 5.239 }, { "text": "tolerate something like this if I do", "start": 522.36, "duration": 4.919 }, { "text": "mailin at just say Harvard I think at", "start": 524.039, "duration": 5.36 }, { "text": "the moment this is going to be invalid", "start": 527.279, "duration": 4.481 }, { "text": "now maybe the top level domain Harvard", "start": 529.399, "duration": 4.241 }, { "text": "exists but at the moment it looks like", "start": 531.76, "duration": 3.24 }, { "text": "we're looking for something more we're", "start": 533.64, "duration": 3.72 }, { "text": "looking for a top level domain too like", "start": 535.0, "duration": 4.6 }, { "text": "edu so for now we'll just consider for", "start": 537.36, "duration": 5.479 }, { "text": "this to be invalid but it's not just", "start": 539.6, "duration": 6.08 }, { "text": "that we want to do it's not just that we", "start": 542.839, "duration": 3.961 }, { "text": "want to check for the presence of a", "start": 545.68, "duration": 2.92 }, { "text": "username and the presence of a dot let's", "start": 546.8, "duration": 3.279 }, { "text": "be more specific let's start to now", "start": 548.6, "duration": 2.919 }, { "text": "narrow the scope of this program not", "start": 550.079, "duration": 3.041 }, { "text": "just to be about generic emails more", "start": 551.519, "duration": 4.32 }, { "text": "generally but about edu addresses so", "start": 553.12, "duration": 4.56 }, { "text": "specifically for someone in a US", "start": 555.839, "duration": 3.281 }, { "text": "University for instance whose email", "start": 557.68, "duration": 4.399 }, { "text": "address tends to end with doedu I can be", "start": 559.12, "duration": 4.52 }, { "text": "a little more precise and you might", "start": 562.079, "duration": 3.841 }, { "text": "recall this function already instead of", "start": 563.64, "duration": 4.24 }, { "text": "just saying is there a DOT somewhere in", "start": 565.92, "duration": 5.359 }, { "text": "domain let me instead say and the domain", "start": 567.88, "duration": 6.92 }, { "text": "ends with quote unquote. edu so now", "start": 571.279, "duration": 5.361 }, { "text": "we're being even more precise we want", "start": 574.8, "duration": 3.68 }, { "text": "there to be minimally a username that's", "start": 576.64, "duration": 3.96 }, { "text": "not empty it's not just quote unquote", "start": 578.48, "duration": 4.359 }, { "text": "nothing and we want the domain name to", "start": 580.6, "duration": 5.32 }, { "text": "actually end with doedu let me go ahead", "start": 582.839, "duration": 5.161 }, { "text": "and run python of validate dopy and just", "start": 585.92, "duration": 3.4 }, { "text": "to make sure I haven't made things even", "start": 588.0, "duration": 3.2 }, { "text": "worse let me at least chest my own email", "start": 589.32, "duration": 4.32 }, { "text": "address which does seem to be valid now", "start": 591.2, "duration": 3.879 }, { "text": "it seems that I minimally need to", "start": 593.64, "duration": 3.12 }, { "text": "provide a username because we definitely", "start": 595.079, "duration": 3.601 }, { "text": "do have that check in place so I'm going", "start": 596.76, "duration": 4.079 }, { "text": "to go ahead and say mailin and now I'm", "start": 598.68, "duration": 4.56 }, { "text": "going to go ahead and say at and it", "start": 600.839, "duration": 4.721 }, { "text": "looks like I could be a little malicious", "start": 603.24, "duration": 4.839 }, { "text": "here just say maen at.edu as though", "start": 605.56, "duration": 4.279 }, { "text": "minimally meeting the requirements of", "start": 608.079, "duration": 3.961 }, { "text": "this of this pattern and that of course", "start": 609.839, "duration": 4.401 }, { "text": "is considered valid but I'm pretty sure", "start": 612.04, "duration": 5.44 }, { "text": "there's no one at mailin at.edu we need", "start": 614.24, "duration": 5.279 }, { "text": "to have some domain name in there so", "start": 617.48, "duration": 3.919 }, { "text": "we're still not being quite as generous", "start": 619.519, "duration": 3.481 }, { "text": "now we could absolutely continue to", "start": 621.399, "duration": 3.68 }, { "text": "iterate on this program and we could add", "start": 623.0, "duration": 3.76 }, { "text": "some more Boolean Expressions we could", "start": 625.079, "duration": 3.681 }, { "text": "maybe use some other python methods for", "start": 626.76, "duration": 3.48 }, { "text": "checking more precisely is there's", "start": 628.76, "duration": 3.0 }, { "text": "something to the left of the dot to the", "start": 630.24, "duration": 3.279 }, { "text": "right of the dot we could use split", "start": 631.76, "duration": 3.4 }, { "text": "multiple times but honestly this just", "start": 633.519, "duration": 3.481 }, { "text": "escalates quickly like you end up having", "start": 635.16, "duration": 4.88 }, { "text": "to write a lot of code just to express", "start": 637.0, "duration": 4.8 }, { "text": "something that's relatively simple in", "start": 640.04, "duration": 4.76 }, { "text": "spirit just format this like an email", "start": 641.8, "duration": 5.68 }, { "text": "address so how can we go about improving", "start": 644.8, "duration": 4.92 }, { "text": "this well it turns out in Python there's", "start": 647.48, "duration": 4.919 }, { "text": "a library for regular Expressions it's", "start": 649.72, "duration": 5.359 }, { "text": "called succinctly re and in the re", "start": 652.399, "duration": 4.761 }, { "text": "Library you have a lot of capabilities", "start": 655.079, "duration": 5.721 }, { "text": "to Define and check for and even replace", "start": 657.16, "duration": 5.88 }, { "text": "patterns again a regular expression is a", "start": 660.8, "duration": 4.8 }, { "text": "pattern and this Library the re library", "start": 663.04, "duration": 4.039 }, { "text": "in Python is going to let us to Define", "start": 665.6, "duration": 2.84 }, { "text": "some of these patterns like a pattern", "start": 667.079, "duration": 3.041 }, { "text": "for an email address and then use some", "start": 668.44, "duration": 4.12 }, { "text": "built-in functions to actually validate", "start": 670.12, "duration": 4.399 }, { "text": "a user's input against that pattern or", "start": 672.56, "duration": 3.92 }, { "text": "even use these patterns to change the", "start": 674.519, "duration": 4.0 }, { "text": "user's input or extract partial", "start": 676.48, "duration": 3.4 }, { "text": "information there from we'll see", "start": 678.519, "duration": 4.12 }, { "text": "examples of all this and more so what", "start": 679.88, "duration": 4.48 }, { "text": "can and should I do with this Library", "start": 682.639, "duration": 3.041 }, { "text": "well first and foremost it comes with a", "start": 684.36, "duration": 3.159 }, { "text": "lot of functionality here's the URL for", "start": 685.68, "duration": 4.12 }, { "text": "instance to the official documentation", "start": 687.519, "duration": 3.721 }, { "text": "and let me propose that we focus on", "start": 689.8, "duration": 3.24 }, { "text": "using one of the most versatile", "start": 691.24, "duration": 4.039 }, { "text": "functions in the library library namely", "start": 693.04, "duration": 5.599 }, { "text": "this search re. search is the name of", "start": 695.279, "duration": 5.441 }, { "text": "the function in the re module that", "start": 698.639, "duration": 4.121 }, { "text": "allows you to pass in a few arguments", "start": 700.72, "duration": 3.96 }, { "text": "the first is going to be a pattern that", "start": 702.76, "duration": 4.48 }, { "text": "you want to search for in for instance a", "start": 704.68, "duration": 5.12 }, { "text": "string that came from a user the string", "start": 707.24, "duration": 4.24 }, { "text": "argument here is going to be the actual", "start": 709.8, "duration": 3.039 }, { "text": "string that you want to search for that", "start": 711.48, "duration": 2.84 }, { "text": "pattern and then there's a third", "start": 712.839, "duration": 3.12 }, { "text": "argument optionally that's a whole bunch", "start": 714.32, "duration": 4.28 }, { "text": "of flags a flag in general is like a a", "start": 715.959, "duration": 4.641 }, { "text": "parameter you can can pass in to modify", "start": 718.6, "duration": 3.28 }, { "text": "the behavior of the function but", "start": 720.6, "duration": 2.64 }, { "text": "initially we're not even going to use", "start": 721.88, "duration": 2.759 }, { "text": "this we're just going to pass in a", "start": 723.24, "duration": 4.08 }, { "text": "couple of arguments instead so let me go", "start": 724.639, "duration": 6.161 }, { "text": "ahead and employ this re Library this", "start": 727.32, "duration": 5.84 }, { "text": "regular expression library and just", "start": 730.8, "duration": 4.56 }, { "text": "improve on this design incrementally so", "start": 733.16, "duration": 3.44 }, { "text": "we're not going to solve this problem", "start": 735.36, "duration": 2.919 }, { "text": "all at once but we'll take some", "start": 736.6, "duration": 3.679 }, { "text": "incremental steps I'm going to go back", "start": 738.279, "duration": 4.321 }, { "text": "to VSS code here and I'm going to go", "start": 740.279, "duration": 4.281 }, { "text": "ahead now and get rid of most of this", "start": 742.6, "duration": 3.96 }, { "text": "code but I'm going to go into the top of", "start": 744.56, "duration": 4.92 }, { "text": "my file and first and all import this re", "start": 746.56, "duration": 5.2 }, { "text": "Library so import re gives me access to", "start": 749.48, "duration": 4.359 }, { "text": "that function and more now after I've", "start": 751.76, "duration": 3.72 }, { "text": "gotten the user's input in the same way", "start": 753.839, "duration": 3.641 }, { "text": "as before stripping off any leading or", "start": 755.48, "duration": 3.88 }, { "text": "trailing whitespace I'm just going to", "start": 757.48, "duration": 4.2 }, { "text": "use this function super trivially for", "start": 759.36, "duration": 4.159 }, { "text": "now even though this isn't really a big", "start": 761.68, "duration": 5.04 }, { "text": "step forward I'm going to say if re.", "start": 763.519, "duration": 6.921 }, { "text": "search contains quote unquote at in the", "start": 766.72, "duration": 5.72 }, { "text": "email address then let's go ahead and", "start": 770.44, "duration": 4.24 }, { "text": "print valid else let's go ahead and", "start": 772.44, "duration": 4.6 }, { "text": "print invalid at the moment this is", "start": 774.68, "duration": 4.56 }, { "text": "really no better than my very first", "start": 777.04, "duration": 4.239 }, { "text": "version where I was just asking python", "start": 779.24, "duration": 5.599 }, { "text": "if at sign in the email address but now", "start": 781.279, "duration": 5.081 }, { "text": "I'm at least beginning to use this", "start": 784.839, "duration": 3.961 }, { "text": "Library by using its own re. search", "start": 786.36, "duration": 4.479 }, { "text": "function which for now you can assume", "start": 788.8, "duration": 5.479 }, { "text": "returns a a True Value effectively if", "start": 790.839, "duration": 6.041 }, { "text": "indeed the at sign is an email just to", "start": 794.279, "duration": 4.481 }, { "text": "make sure that this version does work as", "start": 796.88, "duration": 3.56 }, { "text": "I expect let me go ahead and run python", "start": 798.76, "duration": 4.28 }, { "text": "of validate dopy and enter I'll type in", "start": 800.44, "duration": 5.0 }, { "text": "my actual email address and we're back", "start": 803.04, "duration": 4.64 }, { "text": "in business but of course this is not", "start": 805.44, "duration": 4.16 }, { "text": "great because if I similar Lally run", "start": 807.68, "duration": 3.48 }, { "text": "this version of the program and just", "start": 809.6, "duration": 3.76 }, { "text": "type in an at sign not an email address", "start": 811.16, "duration": 3.919 }, { "text": "and yet my code of course thinks it is", "start": 813.36, "duration": 4.68 }, { "text": "valid so how can I do better than this", "start": 815.079, "duration": 5.56 }, { "text": "well we need a bit more vocabulary in", "start": 818.04, "duration": 4.4 }, { "text": "the realm of regular expressions in", "start": 820.639, "duration": 4.281 }, { "text": "order to be able to express ourselves a", "start": 822.44, "duration": 5.0 }, { "text": "little more precisely really the pattern", "start": 824.92, "duration": 4.4 }, { "text": "I want to ultimately Define is going to", "start": 827.44, "duration": 3.72 }, { "text": "be something like I want there to be", "start": 829.32, "duration": 4.439 }, { "text": "something to the left then an at sign", "start": 831.16, "duration": 4.44 }, { "text": "then something to the right and that", "start": 833.759, "duration": 3.841 }, { "text": "something to the right should end with", "start": 835.6, "duration": 4.0 }, { "text": "edu but should also have something", "start": 837.6, "duration": 4.64 }, { "text": "before the edu like Harvard or Yale or", "start": 839.6, "duration": 5.4 }, { "text": "any other school in the US as well well", "start": 842.24, "duration": 4.48 }, { "text": "how can I go about doing this well it", "start": 845.0, "duration": 4.32 }, { "text": "turns out that in the world of regular", "start": 846.72, "duration": 4.679 }, { "text": "Expressions whether in python or a lot", "start": 849.32, "duration": 3.879 }, { "text": "of other languages as well there's", "start": 851.399, "duration": 3.481 }, { "text": "certain symbols that you can use to", "start": 853.199, "duration": 4.08 }, { "text": "define patterns at the moment I've just", "start": 854.88, "duration": 4.879 }, { "text": "used literal raw text if I go back to my", "start": 857.279, "duration": 5.12 }, { "text": "code here this technically qualifies as", "start": 859.759, "duration": 5.561 }, { "text": "a regular expression I've passed in a", "start": 862.399, "duration": 5.521 }, { "text": "quoted string inside of which is an at", "start": 865.32, "duration": 4.72 }, { "text": "sign now that's not a very interesting", "start": 867.92, "duration": 3.839 }, { "text": "pattern it's just an at sign but it", "start": 870.04, "duration": 3.28 }, { "text": "turns out that once you have access to", "start": 871.759, "duration": 3.401 }, { "text": "regular expressions or a library that", "start": 873.32, "duration": 4.079 }, { "text": "offers that feature you can more", "start": 875.16, "duration": 5.239 }, { "text": "powerfully express yourself as follows", "start": 877.399, "duration": 4.841 }, { "text": "let me reveal that the pattern that you", "start": 880.399, "duration": 4.081 }, { "text": "passed to re. search can take a whole", "start": 882.24, "duration": 4.08 }, { "text": "bunch of special symbols and here's just", "start": 884.48, "duration": 3.919 }, { "text": "some of them in the examples we're about", "start": 886.32, "duration": 4.4 }, { "text": "to see in the patterns we're about to", "start": 888.399, "duration": 4.841 }, { "text": "Define here are the special symbols you", "start": 890.72, "duration": 4.96 }, { "text": "can use a single period a DOT to just", "start": 893.24, "duration": 4.599 }, { "text": "represent any character except a new", "start": 895.68, "duration": 4.399 }, { "text": "line a blank line so that is to say if I", "start": 897.839, "duration": 3.8 }, { "text": "don't really care what letters of the", "start": 900.079, "duration": 3.601 }, { "text": "alphabet are in the user's username I", "start": 901.639, "duration": 3.521 }, { "text": "just want there to be one or more", "start": 903.68, "duration": 4.2 }, { "text": "characters uh in the user's name dot", "start": 905.16, "duration": 4.84 }, { "text": "allows me to express a through z", "start": 907.88, "duration": 4.0 }, { "text": "uppercase and lowercase and a bunch of", "start": 910.0, "duration": 5.16 }, { "text": "other letters as well star is going to", "start": 911.88, "duration": 5.959 }, { "text": "mean in single asterisk zero or more", "start": 915.16, "duration": 5.599 }, { "text": "repetitions so if I say something star", "start": 917.839, "duration": 4.68 }, { "text": "that means that I'm willing to accept", "start": 920.759, "duration": 4.08 }, { "text": "either zero repetitions that is nothing", "start": 922.519, "duration": 5.76 }, { "text": "at all or more repetitions one or two or", "start": 924.839, "duration": 4.881 }, { "text": "three or 300", "start": 928.279, "duration": 3.56 }, { "text": "if you see a plus in my patterns that's", "start": 929.72, "duration": 4.4 }, { "text": "going to mean one or more repetitions", "start": 931.839, "duration": 3.24 }, { "text": "that is to say there's got to be at", "start": 934.12, "duration": 3.279 }, { "text": "least one character there one symbol and", "start": 935.079, "duration": 5.161 }, { "text": "then there's optionally more after that", "start": 937.399, "duration": 4.92 }, { "text": "and then you can say zero or one", "start": 940.24, "duration": 4.039 }, { "text": "repetition you can use a single question", "start": 942.319, "duration": 4.361 }, { "text": "mark after a symbol and that will say I", "start": 944.279, "duration": 5.441 }, { "text": "want zero of this character or one but", "start": 946.68, "duration": 5.56 }, { "text": "that's all I'll expect and then lastly", "start": 949.72, "duration": 3.919 }, { "text": "there's going to be a way to specify a", "start": 952.24, "duration": 3.24 }, { "text": "specific number of symbols if you use", "start": 953.639, "duration": 3.68 }, { "text": "these curly braces and a number", "start": 955.48, "duration": 3.88 }, { "text": "represented here symbolically as m you", "start": 957.319, "duration": 4.161 }, { "text": "can specify that you want M repetitions", "start": 959.36, "duration": 4.56 }, { "text": "be it one or two or three or 300 you can", "start": 961.48, "duration": 4.0 }, { "text": "specify the number of repetitions", "start": 963.92, "duration": 3.32 }, { "text": "yourself and if you want a range of", "start": 965.48, "duration": 3.68 }, { "text": "repetitions like you want this few", "start": 967.24, "duration": 4.0 }, { "text": "characters or this many characters you", "start": 969.16, "duration": 4.039 }, { "text": "can use curly braces and two numbers", "start": 971.24, "duration": 4.44 }, { "text": "inside called here M and N which would", "start": 973.199, "duration": 5.481 }, { "text": "be a range of M through n repetitions", "start": 975.68, "duration": 4.519 }, { "text": "now what does all of this mean well let", "start": 978.68, "duration": 3.76 }, { "text": "me go back to vs code here and let me", "start": 980.199, "duration": 4.76 }, { "text": "propose that we iterate on this solution", "start": 982.44, "duration": 4.519 }, { "text": "further it's not sufficient to just", "start": 984.959, "duration": 3.44 }, { "text": "check for the at sign we know that", "start": 986.959, "duration": 3.081 }, { "text": "already we minimally want something to", "start": 988.399, "duration": 3.92 }, { "text": "the left and to the right so how can I", "start": 990.04, "duration": 4.32 }, { "text": "represent that I don't really care what", "start": 992.319, "duration": 4.32 }, { "text": "the user's username is or what letters", "start": 994.36, "duration": 4.56 }, { "text": "of the alphabet are in it be it men or", "start": 996.639, "duration": 4.361 }, { "text": "anyone else's so what I'm going to do to", "start": 998.92, "duration": 3.919 }, { "text": "the left of this equal sign is I'm going", "start": 1001.0, "duration": 4.72 }, { "text": "to use a single period the dot that", "start": 1002.839, "duration": 5.68 }, { "text": "again indicates any character except for", "start": 1005.72, "duration": 4.88 }, { "text": "a new line but I don't just want a", "start": 1008.519, "duration": 4.0 }, { "text": "single character otherwise the P", "start": 1010.6, "duration": 4.44 }, { "text": "person's username could only be a at", "start": 1012.519, "duration": 5.12 }, { "text": "such and such or B at such and such I", "start": 1015.04, "duration": 4.919 }, { "text": "want it to be multiple such characters", "start": 1017.639, "duration": 4.68 }, { "text": "so I'm going to initially use a star so", "start": 1019.959, "duration": 4.201 }, { "text": "star means give me something to the left", "start": 1022.319, "duration": 4.0 }, { "text": "and I'm going to do another one star", "start": 1024.16, "duration": 4.48 }, { "text": "something to the right now this isn't", "start": 1026.319, "duration": 4.281 }, { "text": "perfect but it's at least a step forward", "start": 1028.64, "duration": 3.159 }, { "text": "because now what I'm going to go ahead", "start": 1030.6, "duration": 3.199 }, { "text": "and do is this I'm going to rerun python", "start": 1031.799, "duration": 3.961 }, { "text": "to validate I'm going to keep testing my", "start": 1033.799, "duration": 3.361 }, { "text": "own email address just to make sure I", "start": 1035.76, "duration": 3.4 }, { "text": "haven't made things worse and that's now", "start": 1037.16, "duration": 4.0 }, { "text": "okay I'm now going to go ahead and type", "start": 1039.16, "duration": 5.48 }, { "text": "in some other input like how about just", "start": 1041.16, "duration": 6.44 }, { "text": "uh mailin at with no domain name", "start": 1044.64, "duration": 4.56 }, { "text": "whatsoever and you would think this is", "start": 1047.6, "duration": 5.16 }, { "text": "going to be invalid but but but it's", "start": 1049.2, "duration": 6.599 }, { "text": "still considered valid but why is that", "start": 1052.76, "duration": 6.0 }, { "text": "if I go back to this chart why is maen", "start": 1055.799, "duration": 7.601 }, { "text": "at with no domain now considered valid", "start": 1058.76, "duration": 8.12 }, { "text": "what's my mistake here by having used", "start": 1063.4, "duration": 6.48 }, { "text": "star at. star as my regular expression", "start": 1066.88, "duration": 5.56 }, { "text": "or Rex because you're using the star", "start": 1069.88, "duration": 5.44 }, { "text": "instead of the plus sign exactly the", "start": 1072.44, "duration": 4.84 }, { "text": "star again means zero or more", "start": 1075.32, "duration": 4.8 }, { "text": "repetitions so re e. search is perfectly", "start": 1077.28, "duration": 4.92 }, { "text": "happy to accept nothing after the equ", "start": 1080.12, "duration": 3.84 }, { "text": "after the at sign because that would be", "start": 1082.2, "duration": 4.04 }, { "text": "zero repetitions so I think I minimally", "start": 1083.96, "duration": 4.24 }, { "text": "need to evolve this and go back to my", "start": 1086.24, "duration": 3.88 }, { "text": "code here and let me go ahead and change", "start": 1088.2, "duration": 5.64 }, { "text": "this from Star to plus and let me change", "start": 1090.12, "duration": 7.16 }, { "text": "the ending from Star to plus so that now", "start": 1093.84, "duration": 5.64 }, { "text": "when I run my code here let me go ahead", "start": 1097.28, "duration": 4.279 }, { "text": "and run python of validate dopy I'm", "start": 1099.48, "duration": 4.16 }, { "text": "going to test my email addresses always", "start": 1101.559, "duration": 4.24 }, { "text": "still working now let me go ahead and", "start": 1103.64, "duration": 4.0 }, { "text": "type in that same thing from before that", "start": 1105.799, "duration": 4.481 }, { "text": "was accidentally considered valid now I", "start": 1107.64, "duration": 5.24 }, { "text": "hit enter finally it's invalid so now", "start": 1110.28, "duration": 4.639 }, { "text": "we're making some progress on being a", "start": 1112.88, "duration": 3.88 }, { "text": "little more precise as to what it is", "start": 1114.919, "duration": 4.081 }, { "text": "we're doing now I'll note here like with", "start": 1116.76, "duration": 4.56 }, { "text": "almost everything in programming python", "start": 1119.0, "duration": 4.44 }, { "text": "included there's often multiple ways to", "start": 1121.32, "duration": 4.88 }, { "text": "solve the same problem and does anyone", "start": 1123.44, "duration": 6.359 }, { "text": "see a way in my code here that I could", "start": 1126.2, "duration": 6.56 }, { "text": "make a slight tweak if I forgot that the", "start": 1129.799, "duration": 5.521 }, { "text": "plus operator exists and go back to", "start": 1132.76, "duration": 5.48 }, { "text": "using a star if I allowed you only to", "start": 1135.32, "duration": 5.8 }, { "text": "use Dot and only Stars could you", "start": 1138.24, "duration": 6.76 }, { "text": "recreate the notion of plus yes um use", "start": 1141.12, "duration": 6.76 }, { "text": "another dot dot dot star yeah because if", "start": 1145.0, "duration": 4.64 }, { "text": "a DOT means any character we'll just use", "start": 1147.88, "duration": 3.679 }, { "text": "a DOT and then when you want to say or", "start": 1149.64, "duration": 4.36 }, { "text": "more use another Dot and then the star", "start": 1151.559, "duration": 5.0 }, { "text": "so equivalent to dot plus would have", "start": 1154.0, "duration": 5.28 }, { "text": "been dot dotar because the first dot", "start": 1156.559, "duration": 5.161 }, { "text": "means any character and the second pair", "start": 1159.28, "duration": 5.0 }, { "text": "of characters dotar means zero or more", "start": 1161.72, "duration": 4.28 }, { "text": "other characters and to be clear it does", "start": 1164.28, "duration": 3.44 }, { "text": "not have to be the same character just", "start": 1166.0, "duration": 4.0 }, { "text": "by doing Dot or Dot star does not mean", "start": 1167.72, "duration": 5.439 }, { "text": "your whole username needs to be a or a A", "start": 1170.0, "duration": 6.679 }, { "text": "or a AA or A A AA it can vary with each", "start": 1173.159, "duration": 7.0 }, { "text": "symbol it just means zero or more of any", "start": 1176.679, "duration": 5.801 }, { "text": "character back to back so I could do", "start": 1180.159, "duration": 3.801 }, { "text": "this on both the left and the right", "start": 1182.48, "duration": 3.6 }, { "text": "which one is better you know it depends", "start": 1183.96, "duration": 3.92 }, { "text": "I think a an argument could be made that", "start": 1186.08, "duration": 3.76 }, { "text": "this is even more clear because it's", "start": 1187.88, "duration": 3.279 }, { "text": "obvious now that there's a DOT which", "start": 1189.84, "duration": 3.28 }, { "text": "means any character and then there's the", "start": 1191.159, "duration": 3.76 }, { "text": "dot star but if you're in the habit of", "start": 1193.12, "duration": 3.919 }, { "text": "doing this frequently one of the reasons", "start": 1194.919, "duration": 4.441 }, { "text": "things like the plus exist is just to", "start": 1197.039, "duration": 3.841 }, { "text": "consolidate your code into something a", "start": 1199.36, "duration": 3.0 }, { "text": "little more succinct and if you're", "start": 1200.88, "duration": 3.159 }, { "text": "familiar with seeing the plus now maybe", "start": 1202.36, "duration": 3.439 }, { "text": "this is more readable to you so again", "start": 1204.039, "duration": 3.52 }, { "text": "just like with python more generally", "start": 1205.799, "duration": 3.281 }, { "text": "you're going to often see different ways", "start": 1207.559, "duration": 3.041 }, { "text": "to express the same patterns and", "start": 1209.08, "duration": 2.959 }, { "text": "reasonable people might agree or", "start": 1210.6, "duration": 4.4 }, { "text": "disagree as to which way is better than", "start": 1212.039, "duration": 5.321 }, { "text": "another well let me propose to that we", "start": 1215.0, "duration": 4.44 }, { "text": "can think about both of these models a", "start": 1217.36, "duration": 3.64 }, { "text": "little more graphically if this looks a", "start": 1219.44, "duration": 2.92 }, { "text": "little cryptic to you let me go ahead", "start": 1221.0, "duration": 4.12 }, { "text": "and Rewind to the previous incarnation", "start": 1222.36, "duration": 4.36 }, { "text": "of this regular expression which was", "start": 1225.12, "duration": 4.32 }, { "text": "just a single dot star this regular", "start": 1226.72, "duration": 6.12 }, { "text": "expression doar at doar means what again", "start": 1229.44, "duration": 5.16 }, { "text": "it means zero or more characters", "start": 1232.84, "duration": 3.8 }, { "text": "followed by a literal at sign followed", "start": 1234.6, "duration": 4.12 }, { "text": "by zero or more other characters now", "start": 1236.64, "duration": 3.519 }, { "text": "when you pass this pattern in as an", "start": 1238.72, "duration": 3.76 }, { "text": "argument to re. search it's going to", "start": 1240.159, "duration": 4.681 }, { "text": "read it from left to right and then use", "start": 1242.48, "duration": 5.16 }, { "text": "it to try to match against the input", "start": 1244.84, "duration": 4.8 }, { "text": "email in this case that the user typed", "start": 1247.64, "duration": 5.08 }, { "text": "in now how is the computer how is re.", "start": 1249.64, "duration": 5.6 }, { "text": "search going to keep track of whether or", "start": 1252.72, "duration": 4.36 }, { "text": "not the user's email matches this", "start": 1255.24, "duration": 3.559 }, { "text": "pattern well it turns out that that it's", "start": 1257.08, "duration": 3.56 }, { "text": "going to be using a machine of sorts", "start": 1258.799, "duration": 3.321 }, { "text": "implemented in software known as a", "start": 1260.64, "duration": 3.8 }, { "text": "finite State machine or more formally a", "start": 1262.12, "duration": 4.799 }, { "text": "non-deterministic finite automaton and", "start": 1264.44, "duration": 3.96 }, { "text": "the way it works if we depict this", "start": 1266.919, "duration": 4.481 }, { "text": "graphically is as follows the re. search", "start": 1268.4, "duration": 5.72 }, { "text": "function starts over here in a so-called", "start": 1271.4, "duration": 4.399 }, { "text": "start State that's the sort of condition", "start": 1274.12, "duration": 3.6 }, { "text": "in which it begins and then it's going", "start": 1275.799, "duration": 3.961 }, { "text": "to read the user's email address from", "start": 1277.72, "duration": 4.0 }, { "text": "left to right and it's going to decide", "start": 1279.76, "duration": 3.76 }, { "text": "whether or not to stay in this first", "start": 1281.72, "duration": 4.52 }, { "text": "state or transition to the next state so", "start": 1283.52, "duration": 4.72 }, { "text": "for instance in this first state as the", "start": 1286.24, "duration": 4.4 }, { "text": "user is reading my email address maen", "start": 1288.24, "duration": 5.039 }, { "text": "harvard.edu it's going to follow this", "start": 1290.64, "duration": 5.24 }, { "text": "curved edge up and around to itself a", "start": 1293.279, "duration": 4.601 }, { "text": "reflexive Edge and it's labeled dot", "start": 1295.88, "duration": 3.399 }, { "text": "because dot again just means any", "start": 1297.88, "duration": 3.96 }, { "text": "character so as the function is reading", "start": 1299.279, "duration": 4.4 }, { "text": "my email address mail at harvard.edu", "start": 1301.84, "duration": 4.88 }, { "text": "from left to right it's going to follow", "start": 1303.679, "duration": 9.48 }, { "text": "these transitions as follows m a l a n", "start": 1306.72, "duration": 8.319 }, { "text": "and then it's hopefully going to follow", "start": 1313.159, "duration": 4.0 }, { "text": "this transition to the second state", "start": 1315.039, "duration": 4.081 }, { "text": "because there's a literal at sign both", "start": 1317.159, "duration": 3.88 }, { "text": "in this machine as well as in my email", "start": 1319.12, "duration": 3.32 }, { "text": "address then it's going to try to read", "start": 1321.039, "duration": 8.281 }, { "text": "the rest of my address h a r v a r d. e", "start": 1322.44, "duration": 9.68 }, { "text": "du and that's it and then the computer's", "start": 1329.32, "duration": 5.04 }, { "text": "going to check did it end up in a an", "start": 1332.12, "duration": 4.439 }, { "text": "except State a final State that's", "start": 1334.36, "duration": 3.76 }, { "text": "actually depicted here pictorially a", "start": 1336.559, "duration": 3.521 }, { "text": "little differently with double circles", "start": 1338.12, "duration": 3.48 }, { "text": "one inside of the other and that just", "start": 1340.08, "duration": 4.16 }, { "text": "means that if the computer finds itself", "start": 1341.6, "duration": 5.64 }, { "text": "in that second accept state after having", "start": 1344.24, "duration": 5.84 }, { "text": "read all of the users input it is indeed", "start": 1347.24, "duration": 5.679 }, { "text": "a valid email address if by some chance", "start": 1350.08, "duration": 4.56 }, { "text": "the machine somehow ended up stuck in", "start": 1352.919, "duration": 3.321 }, { "text": "that first state which does not have", "start": 1354.64, "duration": 3.039 }, { "text": "double circles and it is therefore not", "start": 1356.24, "duration": 3.12 }, { "text": "an accept state the computer would", "start": 1357.679, "duration": 3.88 }, { "text": "conclude this is an invalid email", "start": 1359.36, "duration": 5.12 }, { "text": "address instead by contrast if we go", "start": 1361.559, "duration": 4.48 }, { "text": "back to my other version of the code", "start": 1364.48, "duration": 4.319 }, { "text": "where I instead had Plus on both the", "start": 1366.039, "duration": 4.681 }, { "text": "left and the right recall that re.", "start": 1368.799, "duration": 3.321 }, { "text": "search is going to use one of these", "start": 1370.72, "duration": 3.559 }, { "text": "State machines in order to decide from", "start": 1372.12, "duration": 4.36 }, { "text": "left to right whether or not to accept", "start": 1374.279, "duration": 5.081 }, { "text": "the user's input like Ma at harbard edu", "start": 1376.48, "duration": 4.72 }, { "text": "can we get from the start state so to", "start": 1379.36, "duration": 4.439 }, { "text": "speak to an accept state to decide Yep", "start": 1381.2, "duration": 4.88 }, { "text": "this was in fact meeting the pattern", "start": 1383.799, "duration": 4.081 }, { "text": "well let's propose that this", "start": 1386.08, "duration": 4.079 }, { "text": "non-deterministic finite automaton look", "start": 1387.88, "duration": 4.159 }, { "text": "like this instead we're going to start", "start": 1390.159, "duration": 4.201 }, { "text": "as before in the leftmost start State", "start": 1392.039, "duration": 4.24 }, { "text": "and we're going to necessarily consume", "start": 1394.36, "duration": 3.96 }, { "text": "one character per this first Edge which", "start": 1396.279, "duration": 3.561 }, { "text": "is labeled with a DOT to indicate that", "start": 1398.32, "duration": 3.28 }, { "text": "we can consume any one character like", "start": 1399.84, "duration": 5.199 }, { "text": "the m in Ma at harvard.edu then we can", "start": 1401.6, "duration": 4.8 }, { "text": "spend some time consuming more", "start": 1405.039, "duration": 4.081 }, { "text": "characters before the at sign so the a a", "start": 1406.4, "duration": 6.92 }, { "text": "l a n then we can consume the at sign", "start": 1409.12, "duration": 5.96 }, { "text": "then we can consume at least one more", "start": 1413.32, "duration": 3.64 }, { "text": "character because recall that the Rex", "start": 1415.08, "duration": 4.92 }, { "text": "has dot plus this time and then we can", "start": 1416.96, "duration": 5.16 }, { "text": "consume even more characters if we want", "start": 1420.0, "duration": 4.32 }, { "text": "so if we first consume the H in", "start": 1422.12, "duration": 7.799 }, { "text": "harvard.edu that then leaves the a r v a", "start": 1424.32, "duration": 11.08 }, { "text": "d and then e du and now here too we're", "start": 1429.919, "duration": 7.24 }, { "text": "at the end of the story but we're in an", "start": 1435.4, "duration": 3.72 }, { "text": "accept state because that's circle at", "start": 1437.159, "duration": 4.321 }, { "text": "the end has two circles total which", "start": 1439.12, "duration": 4.12 }, { "text": "means that if the computer if this", "start": 1441.48, "duration": 4.199 }, { "text": "function finds itself in that accept", "start": 1443.24, "duration": 4.16 }, { "text": "state after reading the entirety of the", "start": 1445.679, "duration": 5.12 }, { "text": "user's input it is too in fact a valid", "start": 1447.4, "duration": 5.72 }, { "text": "email address if by contrast we had", "start": 1450.799, "duration": 4.081 }, { "text": "gotten stuck in one of those other", "start": 1453.12, "duration": 4.2 }, { "text": "states unable to follow a transition one", "start": 1454.88, "duration": 4.48 }, { "text": "of those edges and therefore unable to", "start": 1457.32, "duration": 4.32 }, { "text": "make progress in the user's input from", "start": 1459.36, "duration": 3.96 }, { "text": "left to right then we would have to", "start": 1461.64, "duration": 3.639 }, { "text": "conclude that that email address is in", "start": 1463.32, "duration": 4.479 }, { "text": "fact invalid well how can we go upon", "start": 1465.279, "duration": 4.481 }, { "text": "approving this code further let me", "start": 1467.799, "duration": 3.681 }, { "text": "propose now that we check not only for a", "start": 1469.76, "duration": 4.24 }, { "text": "username and also something after the", "start": 1471.48, "duration": 4.0 }, { "text": "username like a domain name but", "start": 1474.0, "duration": 3.64 }, { "text": "minimally required that the string ends", "start": 1475.48, "duration": 5.04 }, { "text": "with edu as well well I think I could do", "start": 1477.64, "duration": 5.08 }, { "text": "this fairly straightforward not only do", "start": 1480.52, "duration": 3.72 }, { "text": "I want there to be something after the", "start": 1482.72, "duration": 3.839 }, { "text": "at sign like the domain like Harvard I", "start": 1484.24, "duration": 4.72 }, { "text": "want the whole thing to end with", "start": 1486.559, "duration": 5.081 }, { "text": "edu but there's a little bit of danger", "start": 1488.96, "duration": 5.4 }, { "text": "here what have I done wrong by", "start": 1491.64, "duration": 5.08 }, { "text": "implementing my regular expression now", "start": 1494.36, "duration": 5.679 }, { "text": "in this way by using plus", "start": 1496.72, "duration": 8.12 }, { "text": "do.edu what could go wrong with this", "start": 1500.039, "duration": 7.921 }, { "text": "version uh the dot is dot means", "start": 1504.84, "duration": 5.16 }, { "text": "something else in this context where it", "start": 1507.96, "duration": 3.719 }, { "text": "means zero or more repetitions of a", "start": 1510.0, "duration": 3.36 }, { "text": "character which is why it will interpret", "start": 1511.679, "duration": 4.36 }, { "text": "it differently exactly even though I", "start": 1513.36, "duration": 5.48 }, { "text": "mean for it to mean literally edu a", "start": 1516.039, "duration": 5.24 }, { "text": "period and then edu unfortunately in the", "start": 1518.84, "duration": 4.36 }, { "text": "world of regular Expressions dot means", "start": 1521.279, "duration": 4.041 }, { "text": "any character which means that this", "start": 1523.2, "duration": 5.12 }, { "text": "string could technically end in a edu or", "start": 1525.32, "duration": 7.16 }, { "text": "or bedu or cedu and so forth but that's", "start": 1528.32, "duration": 7.12 }, { "text": "not in fact that I want so any instincts", "start": 1532.48, "duration": 5.04 }, { "text": "now as to how I could fix this problem", "start": 1535.44, "duration": 3.68 }, { "text": "and let me demonstrate the problem more", "start": 1537.52, "duration": 3.48 }, { "text": "clearly let me go ahead and run this", "start": 1539.12, "duration": 3.919 }, { "text": "code here let me go ahead and type in", "start": 1541.0, "duration": 5.159 }, { "text": "maen harvard.edu and as always this does", "start": 1543.039, "duration": 5.561 }, { "text": "in fact work but Watch What Happens here", "start": 1546.159, "duration": 5.481 }, { "text": "let me go ahead and do Ma at Harvard and", "start": 1548.6, "duration": 7.0 }, { "text": "then uh M at Harvard question mark edu", "start": 1551.64, "duration": 6.96 }, { "text": "enter that too is valid so I could put", "start": 1555.6, "duration": 4.64 }, { "text": "any character there and it's still going", "start": 1558.6, "duration": 3.48 }, { "text": "to be accepted but I don't want question", "start": 1560.24, "duration": 4.84 }, { "text": "mark edu I want edu literally any", "start": 1562.08, "duration": 5.479 }, { "text": "instincts then for how we can solve this", "start": 1565.08, "duration": 4.92 }, { "text": "problem here how can I get this new", "start": 1567.559, "duration": 4.761 }, { "text": "function re. search and a regular", "start": 1570.0, "duration": 3.919 }, { "text": "expression more generally to literally", "start": 1572.32, "duration": 4.28 }, { "text": "mean a dot might you think you can use", "start": 1573.919, "duration": 5.64 }, { "text": "the uh Escape character the backslash", "start": 1576.6, "duration": 4.84 }, { "text": "indeed the so-called Escape character", "start": 1579.559, "duration": 3.561 }, { "text": "which we've seen before outside of the", "start": 1581.44, "duration": 3.08 }, { "text": "context of regular Expressions when we", "start": 1583.12, "duration": 4.159 }, { "text": "talked about new lines back sln was a", "start": 1584.52, "duration": 4.6 }, { "text": "way of telling the computer I want a new", "start": 1587.279, "duration": 3.441 }, { "text": "line but without actually literally", "start": 1589.12, "duration": 3.159 }, { "text": "hitting enter and moving the cursor", "start": 1590.72, "duration": 3.559 }, { "text": "yourself and you don't want a literal n", "start": 1592.279, "duration": 4.361 }, { "text": "on the screen so back sln was a way to", "start": 1594.279, "duration": 4.241 }, { "text": "escape and and convey that you want a", "start": 1596.64, "duration": 3.68 }, { "text": "new line it turns out regular", "start": 1598.52, "duration": 3.44 }, { "text": "Expressions use a similar technique to", "start": 1600.32, "duration": 3.959 }, { "text": "solve this problem here in fact let me", "start": 1601.96, "duration": 4.4 }, { "text": "go into my regular expression and before", "start": 1604.279, "duration": 4.201 }, { "text": "that final dot let me put a single", "start": 1606.36, "duration": 4.039 }, { "text": "backslash in the world of regular", "start": 1608.48, "duration": 3.88 }, { "text": "Expressions this is a so-called special", "start": 1610.399, "duration": 4.081 }, { "text": "sequence and it indicates per this", "start": 1612.36, "duration": 3.96 }, { "text": "backslash and a single dot that I", "start": 1614.48, "duration": 4.04 }, { "text": "literally want to match on a DOT it's", "start": 1616.32, "duration": 3.88 }, { "text": "not that I want to match on any", "start": 1618.52, "duration": 4.0 }, { "text": "character and then edu I want to match", "start": 1620.2, "duration": 5.76 }, { "text": "on a DOT or a period edu but we don't", "start": 1622.52, "duration": 5.84 }, { "text": "want python to misinterpret this", "start": 1625.96, "duration": 4.8 }, { "text": "backslash is beginning a an escape", "start": 1628.36, "duration": 3.96 }, { "text": "sequence something special like backs", "start": 1630.76, "duration": 3.2 }, { "text": "slash n which even though we as the", "start": 1632.32, "duration": 3.2 }, { "text": "programmer might type two characters", "start": 1633.96, "duration": 3.92 }, { "text": "backslash in it really is interpreted by", "start": 1635.52, "duration": 4.72 }, { "text": "python as a single new line we don't", "start": 1637.88, "duration": 4.36 }, { "text": "want any kind of misinterpretation like", "start": 1640.24, "duration": 3.96 }, { "text": "that here so it turns out there's one", "start": 1642.24, "duration": 3.28 }, { "text": "other thing we should do for regular", "start": 1644.2, "duration": 3.359 }, { "text": "expressions like this that have a backs", "start": 1645.52, "duration": 4.68 }, { "text": "slash used in this way I want to specify", "start": 1647.559, "duration": 4.921 }, { "text": "to python that I want this string this", "start": 1650.2, "duration": 4.12 }, { "text": "regular expression in double quotes to", "start": 1652.48, "duration": 4.199 }, { "text": "be treated as a raw string literally", "start": 1654.32, "duration": 3.76 }, { "text": "putting an r at the beginning of the", "start": 1656.679, "duration": 3.0 }, { "text": "string to indicate to python that you", "start": 1658.08, "duration": 3.4 }, { "text": "should not try to interpret any", "start": 1659.679, "duration": 4.281 }, { "text": "backslashes in the usual way I want to", "start": 1661.48, "duration": 4.4 }, { "text": "literally pass the backslash and the dot", "start": 1663.96, "duration": 4.0 }, { "text": "and the edu into this particular", "start": 1665.88, "duration": 4.519 }, { "text": "function search in this case so it's", "start": 1667.96, "duration": 4.48 }, { "text": "similar in spirit to using that F at the", "start": 1670.399, "duration": 3.921 }, { "text": "beginning of a format string which of", "start": 1672.44, "duration": 3.68 }, { "text": "course tells python to format the string", "start": 1674.32, "duration": 3.88 }, { "text": "in a certain way plugging in variables", "start": 1676.12, "duration": 3.84 }, { "text": "that might be between curly braces but", "start": 1678.2, "duration": 4.599 }, { "text": "in this case r indicates a raw string", "start": 1679.96, "duration": 5.719 }, { "text": "that I want passed in exactly as is now", "start": 1682.799, "duration": 4.801 }, { "text": "it's only strictly necessary if you are", "start": 1685.679, "duration": 4.521 }, { "text": "in fact using backslashes to indicate", "start": 1687.6, "duration": 4.24 }, { "text": "that you want some special sequence like", "start": 1690.2, "duration": 3.599 }, { "text": "backslash dot but in general it's", "start": 1691.84, "duration": 3.839 }, { "text": "probably good habit to get into to just", "start": 1693.799, "duration": 4.081 }, { "text": "use raw strings for all of your regular", "start": 1695.679, "duration": 3.72 }, { "text": "Expressions so that if you eventually go", "start": 1697.88, "duration": 3.48 }, { "text": "back in make a change make an addition", "start": 1699.399, "duration": 3.52 }, { "text": "you don't accidentally introduce a", "start": 1701.36, "duration": 3.6 }, { "text": "backslash and then forget that that", "start": 1702.919, "duration": 3.6 }, { "text": "might have some special or", "start": 1704.96, "duration": 3.76 }, { "text": "misinterpreted meaning well let me go", "start": 1706.519, "duration": 3.481 }, { "text": "ahead and try this new regular", "start": 1708.72, "duration": 3.24 }, { "text": "expression I'll clear my terminal window", "start": 1710.0, "duration": 5.48 }, { "text": "run python of validate run python of", "start": 1711.96, "duration": 5.839 }, { "text": "validate dopy and then I'll type in my", "start": 1715.48, "duration": 4.72 }, { "text": "email address correctly maen harvard.edu", "start": 1717.799, "duration": 4.961 }, { "text": "and that's fortunately still valid Let", "start": 1720.2, "duration": 4.28 }, { "text": "Me Clear My screen and run it one more", "start": 1722.76, "duration": 4.2 }, { "text": "time python of validate dopy and this", "start": 1724.48, "duration": 5.559 }, { "text": "time let's mistype it as maen Harvard", "start": 1726.96, "duration": 5.4 }, { "text": "questionmark edu whereby there's", "start": 1730.039, "duration": 4.041 }, { "text": "obviously not a DOT there but there is", "start": 1732.36, "duration": 4.08 }, { "text": "some other Single Character that last", "start": 1734.08, "duration": 4.52 }, { "text": "time was misinterpreted as valid", "start": 1736.44, "duration": 4.359 }, { "text": "but this time now that I've improved my", "start": 1738.6, "duration": 4.799 }, { "text": "regular expression it's discovered as", "start": 1740.799, "duration": 6.521 }, { "text": "indeed invalid any questions now on this", "start": 1743.399, "duration": 6.721 }, { "text": "technique for matching something to the", "start": 1747.32, "duration": 4.56 }, { "text": "left of the at sign something to the", "start": 1750.12, "duration": 4.96 }, { "text": "right and now ending with edu explicitly", "start": 1751.88, "duration": 6.08 }, { "text": "um what happens when use", "start": 1755.08, "duration": 5.36 }, { "text": "that a good question and you kind of", "start": 1757.96, "duration": 3.959 }, { "text": "called me out here well when in doubt", "start": 1760.44, "duration": 4.52 }, { "text": "let's try let me go ahead and do python", "start": 1761.919, "duration": 5.12 }, { "text": "invalidate dopy", "start": 1764.96, "duration": 5.839 }, { "text": "mailin harvard.edu which also is", "start": 1767.039, "duration": 6.24 }, { "text": "incorrect unfortunately my code thinks", "start": 1770.799, "duration": 5.0 }, { "text": "it's valid so another problem to solve", "start": 1773.279, "duration": 4.601 }, { "text": "but a shortcoming for now other", "start": 1775.799, "duration": 4.561 }, { "text": "questions on these regular Expressions", "start": 1777.88, "duration": 6.679 }, { "text": "thus far can you use curly brackets M", "start": 1780.36, "duration": 6.919 }, { "text": "instead of backslash can you use curly", "start": 1784.559, "duration": 4.401 }, { "text": "brackets instead of backslash not in", "start": 1787.279, "duration": 3.361 }, { "text": "this case if you want a literal dot", "start": 1788.96, "duration": 3.959 }, { "text": "backslash dot is the way to do it", "start": 1790.64, "duration": 4.12 }, { "text": "literally how about one other question", "start": 1792.919, "duration": 4.76 }, { "text": "on regular Expressions is this the same", "start": 1794.76, "duration": 5.519 }, { "text": "thing that that Google forms uses in", "start": 1797.679, "duration": 5.561 }, { "text": "order to categorize data in let's say", "start": 1800.279, "duration": 5.721 }, { "text": "some if you've got multiple people", "start": 1803.24, "duration": 6.08 }, { "text": "sending in requests about some feedback", "start": 1806.0, "duration": 5.76 }, { "text": "do they categorize the data that they", "start": 1809.32, "duration": 4.52 }, { "text": "get using this particular regular", "start": 1811.76, "duration": 3.6 }, { "text": "expression thing indeed if you've ever", "start": 1813.84, "duration": 3.719 }, { "text": "used Google forms to not just submit it", "start": 1815.36, "duration": 4.72 }, { "text": "but to create a Google form one of the", "start": 1817.559, "duration": 4.921 }, { "text": "menu options is for response validation", "start": 1820.08, "duration": 4.24 }, { "text": "in English at least and what that allows", "start": 1822.48, "duration": 3.52 }, { "text": "you to do is specify that the user has", "start": 1824.32, "duration": 5.68 }, { "text": "to input an email address or URL uh or a", "start": 1826.0, "duration": 5.88 }, { "text": "string of some length but there's an", "start": 1830.0, "duration": 3.6 }, { "text": "even more powerful feature that some of", "start": 1831.88, "duration": 3.519 }, { "text": "you may not have ever noticed and indeed", "start": 1833.6, "duration": 3.64 }, { "text": "if you'd like to open up Google forms", "start": 1835.399, "duration": 3.961 }, { "text": "create a new form temporarily and poke", "start": 1837.24, "duration": 4.319 }, { "text": "around you will actually see in English", "start": 1839.36, "duration": 4.199 }, { "text": "at least quote unquote regular", "start": 1841.559, "duration": 3.681 }, { "text": "expression mentioned as one of the", "start": 1843.559, "duration": 3.641 }, { "text": "mechanisms you can use to validate your", "start": 1845.24, "duration": 4.36 }, { "text": "users's input into your Google form so", "start": 1847.2, "duration": 4.52 }, { "text": "in fact after today you can start", "start": 1849.6, "duration": 4.079 }, { "text": "avoiding these specific dropdowns of", "start": 1851.72, "duration": 3.76 }, { "text": "like email address or URL or the like", "start": 1853.679, "duration": 4.36 }, { "text": "and you can express your own patterns", "start": 1855.48, "duration": 4.919 }, { "text": "precisely as well regular Expressions", "start": 1858.039, "duration": 4.961 }, { "text": "can even be used in VSS code itself if", "start": 1860.399, "duration": 5.041 }, { "text": "you go and find or do a find and replace", "start": 1863.0, "duration": 4.48 }, { "text": "in vs code you can of course just type", "start": 1865.44, "duration": 4.199 }, { "text": "in words like you could into Microsoft", "start": 1867.48, "duration": 4.84 }, { "text": "Word or Google Docs you can also type if", "start": 1869.639, "duration": 4.561 }, { "text": "you check the right box regular", "start": 1872.32, "duration": 3.92 }, { "text": "expressions and start searching for", "start": 1874.2, "duration": 5.479 }, { "text": "patterns not literally specific values", "start": 1876.24, "duration": 6.039 }, { "text": "well let me propose that we now enhance", "start": 1879.679, "duration": 4.681 }, { "text": "this implementation further by", "start": 1882.279, "duration": 4.081 }, { "text": "introducing a few other symbols because", "start": 1884.36, "duration": 4.52 }, { "text": "right now with my code I keep saying", "start": 1886.36, "duration": 4.439 }, { "text": "that I want my email address to end with", "start": 1888.88, "duration": 5.24 }, { "text": "doedu and start with a username but I'm", "start": 1890.799, "duration": 5.561 }, { "text": "being a little too generous this does in", "start": 1894.12, "duration": 4.12 }, { "text": "fact work as expected for my own email", "start": 1896.36, "duration": 5.48 }, { "text": "address maen harvard.edu but what if I", "start": 1898.24, "duration": 7.2 }, { "text": "type in a sentence like my email address", "start": 1901.84, "duration": 6.679 }, { "text": "is maen harvard.edu and suppose I've", "start": 1905.44, "duration": 4.92 }, { "text": "typed that into the program or I've", "start": 1908.519, "duration": 4.28 }, { "text": "typed that into a Google form is this", "start": 1910.36, "duration": 7.6 }, { "text": "going to be considered valid or invalid", "start": 1912.799, "duration": 7.921 }, { "text": "well let's consider it's got the at sign", "start": 1917.96, "duration": 5.28 }, { "text": "so we're good there it's got one or more", "start": 1920.72, "duration": 4.919 }, { "text": "characters to the left of the at sign", "start": 1923.24, "duration": 4.48 }, { "text": "it's got one or more characters to the", "start": 1925.639, "duration": 5.081 }, { "text": "right of the at sign it's got a literal", "start": 1927.72, "duration": 5.839 }, { "text": "doedu somewhere in there to the right of", "start": 1930.72, "duration": 4.679 }, { "text": "the at sign and granted there's more", "start": 1933.559, "duration": 3.641 }, { "text": "stuff to the right there's literally", "start": 1935.399, "duration": 3.561 }, { "text": "this period at the end of my English", "start": 1937.2, "duration": 4.0 }, { "text": "sentence but that's okay because at the", "start": 1938.96, "duration": 4.16 }, { "text": "moment my regular expression is not so", "start": 1941.2, "duration": 4.68 }, { "text": "precise as to say the pattern must start", "start": 1943.12, "duration": 6.2 }, { "text": "with the username and end with the edu", "start": 1945.88, "duration": 5.759 }, { "text": "technically it's left unsaid what more", "start": 1949.32, "duration": 4.0 }, { "text": "can be to the left and what more can be", "start": 1951.639, "duration": 4.241 }, { "text": "to the right so when I hit enter now", "start": 1953.32, "duration": 4.199 }, { "text": "you'll see that that whole sentence in", "start": 1955.88, "duration": 3.72 }, { "text": "English is valid and that's obviously", "start": 1957.519, "duration": 3.721 }, { "text": "not what you want in fact consider the", "start": 1959.6, "duration": 4.439 }, { "text": "case of using Google forms or Office 365", "start": 1961.24, "duration": 5.12 }, { "text": "to collect data from users if you don't", "start": 1964.039, "duration": 4.52 }, { "text": "validate your input your users might", "start": 1966.36, "duration": 4.0 }, { "text": "very well type in a full sentence or", "start": 1968.559, "duration": 3.84 }, { "text": "some else with a typographical error not", "start": 1970.36, "duration": 3.88 }, { "text": "an actual email so if you're just trying", "start": 1972.399, "duration": 3.921 }, { "text": "to copy all of the results that have", "start": 1974.24, "duration": 3.36 }, { "text": "been typed into your form so you can", "start": 1976.32, "duration": 3.28 }, { "text": "paste them into Gmail or some email", "start": 1977.6, "duration": 3.64 }, { "text": "program it's going to break because", "start": 1979.6, "duration": 2.84 }, { "text": "you're going to accidentally paste", "start": 1981.24, "duration": 2.799 }, { "text": "something like a whole English sentence", "start": 1982.44, "duration": 3.599 }, { "text": "into the program instead of just an", "start": 1984.039, "duration": 4.041 }, { "text": "email address which is what your mailer", "start": 1986.039, "duration": 4.201 }, { "text": "expects so how can I be more precise", "start": 1988.08, "duration": 3.719 }, { "text": "well let me propose we introduce a few", "start": 1990.24, "duration": 4.319 }, { "text": "more symbols as well it turns out in the", "start": 1991.799, "duration": 4.88 }, { "text": "context of a regular expression one of", "start": 1994.559, "duration": 4.321 }, { "text": "these patterns you can use the carrot", "start": 1996.679, "duration": 4.72 }, { "text": "symbol the little triangular Mark to", "start": 1998.88, "duration": 4.72 }, { "text": "represent that you want this pattern to", "start": 2001.399, "duration": 4.361 }, { "text": "match the start of the string", "start": 2003.6, "duration": 4.36 }, { "text": "specifically not anywhere but the start", "start": 2005.76, "duration": 4.759 }, { "text": "of the user string by contrast you can", "start": 2007.96, "duration": 4.599 }, { "text": "use a dollar sign in your regular", "start": 2010.519, "duration": 4.081 }, { "text": "expression to say that you want to match", "start": 2012.559, "duration": 3.96 }, { "text": "the end of the string or technically", "start": 2014.6, "duration": 3.559 }, { "text": "just before the new line at the end of", "start": 2016.519, "duration": 3.081 }, { "text": "the string but for all intents and", "start": 2018.159, "duration": 3.201 }, { "text": "purposes think of carrot as meaning", "start": 2019.6, "duration": 3.88 }, { "text": "start of the string and dollar sign as", "start": 2021.36, "duration": 5.159 }, { "text": "meaning end of the string it is a weird", "start": 2023.48, "duration": 5.199 }, { "text": "thing that one is a carrot and one is a", "start": 2026.519, "duration": 3.721 }, { "text": "dollar sign these are not really things", "start": 2028.679, "duration": 3.281 }, { "text": "that I think of as opposites like a", "start": 2030.24, "duration": 3.52 }, { "text": "parenthesis or something like that but", "start": 2031.96, "duration": 3.28 }, { "text": "those are the symbols the world chose", "start": 2033.76, "duration": 4.279 }, { "text": "many years ago so let me go back to vs C", "start": 2035.24, "duration": 5.24 }, { "text": "now and let me add this feature to my", "start": 2038.039, "duration": 5.201 }, { "text": "code here let me specify that yes I do", "start": 2040.48, "duration": 4.679 }, { "text": "want to search for this pattern but I", "start": 2043.24, "duration": 4.559 }, { "text": "want the users's input to start with", "start": 2045.159, "duration": 4.641 }, { "text": "this pattern and end with this pattern", "start": 2047.799, "duration": 3.08 }, { "text": "so even though it's going to start", "start": 2049.8, "duration": 3.48 }, { "text": "looking even more cryptic I put a carrot", "start": 2050.879, "duration": 4.561 }, { "text": "symbol here at the beginning and I put a", "start": 2053.28, "duration": 4.399 }, { "text": "dollar sign here at the end that does", "start": 2055.44, "duration": 4.0 }, { "text": "not mean I want the user to type a", "start": 2057.679, "duration": 3.881 }, { "text": "carrot symbol or a dollar sign this is", "start": 2059.44, "duration": 5.12 }, { "text": "special symbology that indicates to re.", "start": 2061.56, "duration": 5.079 }, { "text": "search that it should only look for now", "start": 2064.56, "duration": 5.0 }, { "text": "an exact math against this pattern so if", "start": 2066.639, "duration": 5.24 }, { "text": "I now go back to my terminal window and", "start": 2069.56, "duration": 3.799 }, { "text": "I'll leave the previous result on the", "start": 2071.879, "duration": 3.641 }, { "text": "screen let me type the exact same thing", "start": 2073.359, "duration": 5.201 }, { "text": "my email address is maen harvard.edu", "start": 2075.52, "duration": 6.2 }, { "text": "enter sorry period and now I'm going to", "start": 2078.56, "duration": 5.799 }, { "text": "go ahead and hit enter now that's", "start": 2081.72, "duration": 4.959 }, { "text": "considered invalid but let me clear the", "start": 2084.359, "duration": 3.681 }, { "text": "screen and just to make sure I didn't", "start": 2086.679, "duration": 3.2 }, { "text": "break things let me type in just my", "start": 2088.04, "duration": 5.639 }, { "text": "email address and that too is valid any", "start": 2089.879, "duration": 6.121 }, { "text": "questions now on this version of my", "start": 2093.679, "duration": 4.841 }, { "text": "regular expression which note goes", "start": 2096.0, "duration": 5.68 }, { "text": "further to specify even more precisely", "start": 2098.52, "duration": 5.64 }, { "text": "that I want it to match at the start and", "start": 2101.68, "duration": 3.36 }, { "text": "the", "start": 2104.16, "duration": 4.919 }, { "text": "end any questions on this one here okay", "start": 2105.04, "duration": 7.2 }, { "text": "you have slash and that edu and then the", "start": 2109.079, "duration": 6.721 }, { "text": "dollar sign but the dot is like uh one", "start": 2112.24, "duration": 6.32 }, { "text": "of the regular expression right it", "start": 2115.8, "duration": 5.4 }, { "text": "normally is but this backslash that I", "start": 2118.56, "duration": 6.039 }, { "text": "deliberately put before this period here", "start": 2121.2, "duration": 6.0 }, { "text": "is an escape character it is a way of", "start": 2124.599, "duration": 5.361 }, { "text": "telling re. search that I don't want any", "start": 2127.2, "duration": 4.919 }, { "text": "character there I literally want a", "start": 2129.96, "duration": 4.52 }, { "text": "period there and it's the only way you", "start": 2132.119, "duration": 4.48 }, { "text": "can distinguish one from the other if I", "start": 2134.48, "duration": 4.68 }, { "text": "got rid of that slash this would mean", "start": 2136.599, "duration": 4.441 }, { "text": "that the email address just has to end", "start": 2139.16, "duration": 4.4 }, { "text": "with any character then an e then a d", "start": 2141.04, "duration": 4.52 }, { "text": "then a u i don't want that I want", "start": 2143.56, "duration": 5.0 }, { "text": "literally a period Then the E then the D", "start": 2145.56, "duration": 5.36 }, { "text": "then the U this is actually common", "start": 2148.56, "duration": 4.64 }, { "text": "convention in programming and technology", "start": 2150.92, "duration": 3.919 }, { "text": "in general if you and I decide on a", "start": 2153.2, "duration": 3.48 }, { "text": "convention whereby we're using some", "start": 2154.839, "duration": 3.28 }, { "text": "character on the keyboard to mean", "start": 2156.68, "duration": 3.919 }, { "text": "something special invariably we create a", "start": 2158.119, "duration": 4.401 }, { "text": "future problem for oursel when we want", "start": 2160.599, "duration": 4.441 }, { "text": "to literally use that same character and", "start": 2162.52, "duration": 4.319 }, { "text": "so the solution in general to that", "start": 2165.04, "duration": 3.799 }, { "text": "problem is to somehow escape the", "start": 2166.839, "duration": 3.361 }, { "text": "character so that it's clear to the", "start": 2168.839, "duration": 3.121 }, { "text": "computer that it's not that special", "start": 2170.2, "duration": 4.32 }, { "text": "symbol it's literally the symbol it sees", "start": 2171.96, "duration": 4.56 }, { "text": "so we don't need another we don't need", "start": 2174.52, "duration": 5.64 }, { "text": "another another slash before the dollar", "start": 2176.52, "duration": 7.36 }, { "text": "sign no uh because in this case dollar", "start": 2180.16, "duration": 5.88 }, { "text": "sign means something special per this", "start": 2183.88, "duration": 4.4 }, { "text": "chart here dollar sign by itself does", "start": 2186.04, "duration": 4.76 }, { "text": "not mean US dollars or currency it", "start": 2188.28, "duration": 4.28 }, { "text": "literally means match the end of the", "start": 2190.8, "duration": 4.96 }, { "text": "string if however I wanted the user to", "start": 2192.56, "duration": 5.68 }, { "text": "literally type in a dollar sign at the", "start": 2195.76, "duration": 4.52 }, { "text": "end of their input the solution would be", "start": 2198.24, "duration": 4.359 }, { "text": "the same I would put a backslash before", "start": 2200.28, "duration": 4.4 }, { "text": "the dollar sign which means my email", "start": 2202.599, "duration": 3.48 }, { "text": "address would have to be something like", "start": 2204.68, "duration": 4.56 }, { "text": "maen harvard.edu dollar sign which is", "start": 2206.079, "duration": 5.961 }, { "text": "obviously not correct too so backslashes", "start": 2209.24, "duration": 5.48 }, { "text": "just allow you to tell the computer to", "start": 2212.04, "duration": 4.88 }, { "text": "not treat those symbols specially like", "start": 2214.72, "duration": 4.359 }, { "text": "meaning something special but to treat", "start": 2216.92, "duration": 4.56 }, { "text": "them literally instead how about one", "start": 2219.079, "duration": 4.481 }, { "text": "other question here on regular", "start": 2221.48, "duration": 4.4 }, { "text": "Expressions you said you said one", "start": 2223.56, "duration": 5.519 }, { "text": "represents to to make it one plus then", "start": 2225.88, "duration": 5.04 }, { "text": "you say one was to make it one with", "start": 2229.079, "duration": 5.321 }, { "text": "nothing sure let me rewind in time I", "start": 2230.92, "duration": 4.72 }, { "text": "think what you're referring to was one", "start": 2234.4, "duration": 3.04 }, { "text": "of our earlier versions that initially", "start": 2235.64, "duration": 4.24 }, { "text": "looked like this which just meant Zero", "start": 2237.44, "duration": 5.24 }, { "text": "or more characters than an at sign than", "start": 2239.88, "duration": 5.479 }, { "text": "zero or more other characters we then", "start": 2242.68, "duration": 5.88 }, { "text": "evolved that to be this do Plus on both", "start": 2245.359, "duration": 4.96 }, { "text": "sides which means one or more characters", "start": 2248.56, "duration": 4.12 }, { "text": "on the left then an at sign then one or", "start": 2250.319, "duration": 4.52 }, { "text": "more characters on the right and if I'm", "start": 2252.68, "duration": 4.08 }, { "text": "interpreting your question correctly one", "start": 2254.839, "duration": 3.641 }, { "text": "of the points I made earlier was that if", "start": 2256.76, "duration": 3.88 }, { "text": "you didn't use Plus or forgot that it", "start": 2258.48, "duration": 4.359 }, { "text": "exists you could equivalently achieve", "start": 2260.64, "duration": 4.32 }, { "text": "the exact same result with two dots and", "start": 2262.839, "duration": 5.041 }, { "text": "a star because the first dot means any", "start": 2264.96, "duration": 5.04 }, { "text": "character it's got to be there the", "start": 2267.88, "duration": 5.4 }, { "text": "second dot star means zero or more other", "start": 2270.0, "duration": 5.48 }, { "text": "characters and same on the right so it's", "start": 2273.28, "duration": 4.28 }, { "text": "just another way of expressing the same", "start": 2275.48, "duration": 4.879 }, { "text": "idea one or more can be represented like", "start": 2277.56, "duration": 5.559 }, { "text": "this with DOT do star or you can just", "start": 2280.359, "duration": 5.361 }, { "text": "use the handier syntax of plus which", "start": 2283.119, "duration": 4.601 }, { "text": "means the same thing all right so I dare", "start": 2285.72, "duration": 3.599 }, { "text": "say there's still some problems with the", "start": 2287.72, "duration": 3.48 }, { "text": "regular expression in this current form", "start": 2289.319, "duration": 3.52 }, { "text": "because even though now we're starting", "start": 2291.2, "duration": 2.919 }, { "text": "to look for the username at the", "start": 2292.839, "duration": 3.321 }, { "text": "beginning of the string from the user", "start": 2294.119, "duration": 4.161 }, { "text": "and we're looking for the edu literally", "start": 2296.16, "duration": 4.4 }, { "text": "at the end of the string from the user", "start": 2298.28, "duration": 4.96 }, { "text": "those dots are a little too encompassing", "start": 2300.56, "duration": 4.6 }, { "text": "right now I am allowed to type in more", "start": 2303.24, "duration": 4.839 }, { "text": "than the single at sign why because at", "start": 2305.16, "duration": 4.959 }, { "text": "is a character and Dot means any", "start": 2308.079, "duration": 3.881 }, { "text": "character so honestly I can have as many", "start": 2310.119, "duration": 3.841 }, { "text": "at signs is this thing at the moment as", "start": 2311.96, "duration": 4.28 }, { "text": "I want for instance if I run python of", "start": 2313.96, "duration": 5.119 }, { "text": "validate dopy maen harvard.edu still", "start": 2316.24, "duration": 5.56 }, { "text": "works as expected but if I also run", "start": 2319.079, "duration": 4.881 }, { "text": "python of validate dopy and incorrectly", "start": 2321.8, "duration": 5.68 }, { "text": "do mail harvard.edu that should be", "start": 2323.96, "duration": 6.28 }, { "text": "invalid but it's considered valid", "start": 2327.48, "duration": 4.56 }, { "text": "instead so I think we need to be a", "start": 2330.24, "duration": 4.76 }, { "text": "little more restrictive when it comes to", "start": 2332.04, "duration": 5.039 }, { "text": "that dot and we can't just say oh any", "start": 2335.0, "duration": 4.68 }, { "text": "old character there is fine we need to", "start": 2337.079, "duration": 5.321 }, { "text": "be more specific well it turns out that", "start": 2339.68, "duration": 4.84 }, { "text": "regular Expressions also support this", "start": 2342.4, "duration": 5.08 }, { "text": "syntax you can use square brackets", "start": 2344.52, "duration": 5.44 }, { "text": "inside of your pattern and inside of", "start": 2347.48, "duration": 5.56 }, { "text": "those square brackets include one or", "start": 2349.96, "duration": 5.119 }, { "text": "more characters that you want to look", "start": 2353.04, "duration": 3.079 }, { "text": "for", "start": 2355.079, "duration": 3.721 }, { "text": "specifically alternatively you can", "start": 2356.119, "duration": 4.881 }, { "text": "inside of those square brackets put a", "start": 2358.8, "duration": 4.24 }, { "text": "carrot symbol which unfortunately in", "start": 2361.0, "duration": 3.76 }, { "text": "this context means something completely", "start": 2363.04, "duration": 3.44 }, { "text": "different from match the start of the", "start": 2364.76, "duration": 3.96 }, { "text": "string but would be the complement", "start": 2366.48, "duration": 4.24 }, { "text": "operator inside of these square brackets", "start": 2368.72, "duration": 4.32 }, { "text": "which means you cannot match any of", "start": 2370.72, "duration": 4.639 }, { "text": "these characters so things are about to", "start": 2373.04, "duration": 4.279 }, { "text": "look even more cryptic now but that's", "start": 2375.359, "duration": 3.76 }, { "text": "why we're focusing on regular", "start": 2377.319, "duration": 4.321 }, { "text": "Expressions on their own here if I don't", "start": 2379.119, "duration": 5.2 }, { "text": "want to allow any character which is", "start": 2381.64, "duration": 5.439 }, { "text": "what a DOT is let me go ahead and I", "start": 2384.319, "duration": 5.0 }, { "text": "could just say well I only want to", "start": 2387.079, "duration": 6.161 }, { "text": "support a or B's or C's or D's or E's or", "start": 2389.319, "duration": 5.721 }, { "text": "FS or G's I could type in the whole", "start": 2393.24, "duration": 3.76 }, { "text": "alphabet here plus some numbers to", "start": 2395.04, "duration": 3.799 }, { "text": "actually include all of the letters that", "start": 2397.0, "duration": 4.2 }, { "text": "I do want to allow but honestly a little", "start": 2398.839, "duration": 5.0 }, { "text": "simpler would be this I could use a", "start": 2401.2, "duration": 6.159 }, { "text": "carrot symbol and then in at sign which", "start": 2403.839, "duration": 6.081 }, { "text": "has the effect of saying this is the set", "start": 2407.359, "duration": 5.76 }, { "text": "of characters that has everything except", "start": 2409.92, "duration": 5.56 }, { "text": "an at sign and I can do the same thing", "start": 2413.119, "duration": 4.801 }, { "text": "over here instead of a DOT to the right", "start": 2415.48, "duration": 5.0 }, { "text": "of the at sign I can do Open", "start": 2417.92, "duration": 6.24 }, { "text": "Bracket carrot at sign and I admit", "start": 2420.48, "duration": 5.599 }, { "text": "things are starting to escalate quickly", "start": 2424.16, "duration": 3.72 }, { "text": "here but let's start from the left and", "start": 2426.079, "duration": 4.841 }, { "text": "go to the right this carrot outside of", "start": 2427.88, "duration": 4.56 }, { "text": "the square brackets at the very start of", "start": 2430.92, "duration": 3.84 }, { "text": "my string as before means match from the", "start": 2432.44, "duration": 4.44 }, { "text": "start of the string and let's Jump Ahead", "start": 2434.76, "duration": 3.88 }, { "text": "the dollar sign all the way at the end", "start": 2436.88, "duration": 3.84 }, { "text": "of the regular expression means match at", "start": 2438.64, "duration": 4.04 }, { "text": "the end of the string so if we can", "start": 2440.72, "duration": 3.359 }, { "text": "mentally tick those off as", "start": 2442.68, "duration": 3.36 }, { "text": "straightforward let's now focus on", "start": 2444.079, "duration": 4.321 }, { "text": "everything else in the middle well to", "start": 2446.04, "duration": 4.64 }, { "text": "the left here we have new syntax a", "start": 2448.4, "duration": 6.04 }, { "text": "square bracket another carrot an at sign", "start": 2450.68, "duration": 6.24 }, { "text": "and a closed square bracket and then a", "start": 2454.44, "duration": 4.879 }, { "text": "plus the plus means the same thing as", "start": 2456.92, "duration": 4.8 }, { "text": "always it means one or more of the", "start": 2459.319, "duration": 4.881 }, { "text": "things to the left what is the thing to", "start": 2461.72, "duration": 5.119 }, { "text": "the left well this is the new syntax", "start": 2464.2, "duration": 4.6 }, { "text": "inside of square brackets here I have a", "start": 2466.839, "duration": 4.52 }, { "text": "carrot symbol and then an at sign that", "start": 2468.8, "duration": 5.559 }, { "text": "just means any character accept an at", "start": 2471.359, "duration": 5.401 }, { "text": "sign it's a weird syntax but this is how", "start": 2474.359, "duration": 5.121 }, { "text": "we can express that simple idea any", "start": 2476.76, "duration": 5.72 }, { "text": "character on the keyboard except for an", "start": 2479.48, "duration": 4.92 }, { "text": "at sign and heck even other characters", "start": 2482.48, "duration": 3.4 }, { "text": "that aren't physically on your keyboard", "start": 2484.4, "duration": 3.84 }, { "text": "but that nonetheless exist", "start": 2485.88, "duration": 4.52 }, { "text": "then we have a literal at sign then we", "start": 2488.24, "duration": 3.879 }, { "text": "have another one of these same things", "start": 2490.4, "duration": 4.16 }, { "text": "square bracket carrot at close bracket", "start": 2492.119, "duration": 4.281 }, { "text": "which means any character accept an at", "start": 2494.56, "duration": 4.48 }, { "text": "sign then one or more of those things", "start": 2496.4, "duration": 5.52 }, { "text": "followed by literally a period", "start": 2499.04, "duration": 5.92 }, { "text": "U so now let me go ahead and do this", "start": 2501.92, "duration": 5.679 }, { "text": "again let me rerun python of validate", "start": 2504.96, "duration": 4.399 }, { "text": "dopy and test my own email address to", "start": 2507.599, "duration": 4.041 }, { "text": "make sure I've not made things worse and", "start": 2509.359, "duration": 3.921 }, { "text": "we're good now let me go ahead and clear", "start": 2511.64, "duration": 3.24 }, { "text": "my screen and run python of validate", "start": 2513.28, "duration": 2.96 }, { "text": "dopy again and do", "start": 2514.88, "duration": 4.88 }, { "text": "mailin at harvard.edu crossing my", "start": 2516.24, "duration": 5.92 }, { "text": "fingers this time and finally this now", "start": 2519.76, "duration": 5.559 }, { "text": "is invalid why I'm allowing myself to", "start": 2522.16, "duration": 5.32 }, { "text": "have one at sign in the middle of the", "start": 2525.319, "duration": 4.76 }, { "text": "user's input but everything to the left", "start": 2527.48, "duration": 5.599 }, { "text": "per this new syntax cannot be an at sign", "start": 2530.079, "duration": 5.921 }, { "text": "it can be anything but one or more times", "start": 2533.079, "duration": 4.721 }, { "text": "and everything to the right of the at", "start": 2536.0, "duration": 4.359 }, { "text": "sign can be anything but an at sign one", "start": 2537.8, "duration": 5.4 }, { "text": "or more times followed by lastly a", "start": 2540.359, "duration": 6.161 }, { "text": "literal. edu so again the new syntax is", "start": 2543.2, "duration": 4.6 }, { "text": "quite simply there", "start": 2546.52, "duration": 3.76 }, { "text": "square brackets allow you to specify a", "start": 2547.8, "duration": 4.16 }, { "text": "set of characters that you literally", "start": 2550.28, "duration": 4.44 }, { "text": "type out at your keyboard a b CDE e f or", "start": 2551.96, "duration": 4.96 }, { "text": "the complement the opposite the carrot", "start": 2554.72, "duration": 4.44 }, { "text": "symbol which means not and then the one", "start": 2556.92, "duration": 4.72 }, { "text": "or more symbols you want to", "start": 2559.16, "duration": 5.439 }, { "text": "exclude questions now on this syntax", "start": 2561.64, "duration": 5.84 }, { "text": "here so right after add sign can we use", "start": 2564.599, "duration": 5.401 }, { "text": "the curly brackets M uh one so that we", "start": 2567.48, "duration": 5.0 }, { "text": "can only have one repetition of the add", "start": 2570.0, "duration": 4.64 }, { "text": "symbol absolutely so we could do this", "start": 2572.48, "duration": 4.32 }, { "text": "let me go ahead and pull a VSS code and", "start": 2574.64, "duration": 4.24 }, { "text": "let me delete the current form of a", "start": 2576.8, "duration": 3.519 }, { "text": "regular expression and go back to where", "start": 2578.88, "duration": 5.0 }, { "text": "we began which was justar at andar I", "start": 2580.319, "duration": 5.76 }, { "text": "could absolutely do something like this", "start": 2583.88, "duration": 5.12 }, { "text": "and require that I want at least one of", "start": 2586.079, "duration": 5.361 }, { "text": "any character here and then I could do", "start": 2589.0, "duration": 4.68 }, { "text": "something more to have any more as well", "start": 2591.44, "duration": 4.24 }, { "text": "so the curly brace syntax which we saw", "start": 2593.68, "duration": 3.8 }, { "text": "on the slide earlier but didn't yet use", "start": 2595.68, "duration": 4.0 }, { "text": "absolutely can be used to specify a", "start": 2597.48, "duration": 4.16 }, { "text": "specific number of characters but", "start": 2599.68, "duration": 3.8 }, { "text": "honestly this is more verbose than is", "start": 2601.64, "duration": 4.4 }, { "text": "necessary the best solution arguably or", "start": 2603.48, "duration": 4.76 }, { "text": "the simplest at least ultimately is just", "start": 2606.04, "duration": 4.319 }, { "text": "to say plus but there too another", "start": 2608.24, "duration": 3.76 }, { "text": "example of how you can solve the same", "start": 2610.359, "duration": 4.2 }, { "text": "problem multiple ways let me go back to", "start": 2612.0, "duration": 4.24 }, { "text": "where the regular expression just was", "start": 2614.559, "duration": 4.601 }, { "text": "and take other questions as well", "start": 2616.24, "duration": 6.24 }, { "text": "questions on these sets of characters or", "start": 2619.16, "duration": 6.84 }, { "text": "complimenting that's set so can you use", "start": 2622.48, "duration": 5.879 }, { "text": "that same syntax to say that you don't", "start": 2626.0, "duration": 4.359 }, { "text": "want a certain character throughout the", "start": 2628.359, "duration": 6.081 }, { "text": "whole string you could it's going to be", "start": 2630.359, "duration": 5.561 }, { "text": "uh you could absolutely use the same", "start": 2634.44, "duration": 3.2 }, { "text": "character to exclude", "start": 2635.92, "duration": 4.24 }, { "text": "um you could absolutely use this syntax", "start": 2637.64, "duration": 4.479 }, { "text": "to exclude a certain character from the", "start": 2640.16, "duration": 4.159 }, { "text": "entire string but it would be a little", "start": 2642.119, "duration": 3.601 }, { "text": "harder right now because we're still", "start": 2644.319, "duration": 5.481 }, { "text": "requiring doedu at the end but yes", "start": 2645.72, "duration": 7.04 }, { "text": "absolutely other questions what happens", "start": 2649.8, "duration": 6.44 }, { "text": "if the user inputs do edu in the", "start": 2652.76, "duration": 6.0 }, { "text": "beginning of the string a good question", "start": 2656.24, "duration": 4.68 }, { "text": "what happens if the user types in edu at", "start": 2658.76, "duration": 3.48 }, { "text": "the beginning of the screen well let me", "start": 2660.92, "duration": 3.199 }, { "text": "go back to vs code here and let's try to", "start": 2662.24, "duration": 3.52 }, { "text": "solve this in two different ways first", "start": 2664.119, "duration": 3.401 }, { "text": "let's look at the regular expression and", "start": 2665.76, "duration": 4.24 }, { "text": "see if we can infer if that's going to", "start": 2667.52, "duration": 4.64 }, { "text": "be tolerated well according to the", "start": 2670.0, "duration": 5.28 }, { "text": "current cryptic regular expression I'm", "start": 2672.16, "duration": 5.36 }, { "text": "saying that you can have any character", "start": 2675.28, "duration": 4.44 }, { "text": "except the at sign so that would work I", "start": 2677.52, "duration": 4.96 }, { "text": "could have the dot for the edu but then", "start": 2679.72, "duration": 5.52 }, { "text": "I have to have an at sign so that", "start": 2682.48, "duration": 5.16 }, { "text": "wouldn't really work because if I'm just", "start": 2685.24, "duration": 4.76 }, { "text": "typing in.edu we're not going to pass", "start": 2687.64, "duration": 4.28 }, { "text": "that constraint so now let me try this", "start": 2690.0, "duration": 4.04 }, { "text": "in uh by running the program let me type", "start": 2691.92, "duration": 4.56 }, { "text": "in just literally doedu that doesn't", "start": 2694.04, "duration": 6.92 }, { "text": "work but but but I could do this doedu", "start": 2696.48, "duration": 8.56 }, { "text": "at.edu that too is invalid but let me do", "start": 2700.96, "duration": 7.32 }, { "text": "this uhedu", "start": 2705.04, "duration": 6.72 }, { "text": "something. edu that passes so it's", "start": 2708.28, "duration": 5.4 }, { "text": "starting to get a little weird now maybe", "start": 2711.76, "duration": 3.72 }, { "text": "it's valid maybe it's not but I think", "start": 2713.68, "duration": 4.52 }, { "text": "we'll eventually be more precise too how", "start": 2715.48, "duration": 5.2 }, { "text": "about one more question on this regular", "start": 2718.2, "duration": 4.6 }, { "text": "expression and these complimenting of", "start": 2720.68, "duration": 6.399 }, { "text": "sets can we use uh another domain name", "start": 2722.8, "duration": 6.16 }, { "text": "as a string input can you use another", "start": 2727.079, "duration": 3.841 }, { "text": "domain name absolutely I'm using my own", "start": 2728.96, "duration": 3.52 }, { "text": "just for the sake of demonstration but", "start": 2730.92, "duration": 4.04 }, { "text": "you could absolutely use any domain or", "start": 2732.48, "duration": 4.879 }, { "text": "top level domain and I'm using edu which", "start": 2734.96, "duration": 3.96 }, { "text": "is very us-centric but this would", "start": 2737.359, "duration": 4.48 }, { "text": "absolutely work exactly the same for any", "start": 2738.92, "duration": 5.48 }, { "text": "top level domain all right let me go and", "start": 2741.839, "duration": 4.72 }, { "text": "ahead now and propose that we improve", "start": 2744.4, "duration": 3.84 }, { "text": "this regular expression further because", "start": 2746.559, "duration": 4.401 }, { "text": "if I pull it up again in V vs code here", "start": 2748.24, "duration": 4.599 }, { "text": "you'll see that I'm being a little too", "start": 2750.96, "duration": 4.119 }, { "text": "tolerant still it turns out that there", "start": 2752.839, "duration": 4.561 }, { "text": "are certain requirements for someone's", "start": 2755.079, "duration": 4.721 }, { "text": "username and domain name in an email", "start": 2757.4, "duration": 4.28 }, { "text": "address there is an official standard in", "start": 2759.8, "duration": 3.64 }, { "text": "the world for what an email address can", "start": 2761.68, "duration": 4.28 }, { "text": "be and what characters can be in it and", "start": 2763.44, "duration": 5.52 }, { "text": "this is way too accommodating of all the", "start": 2765.96, "duration": 4.84 }, { "text": "characters in the world except for the", "start": 2768.96, "duration": 4.28 }, { "text": "at symbol so let's actually narrow the", "start": 2770.8, "duration": 3.72 }, { "text": "definition of what we're going to", "start": 2773.24, "duration": 3.56 }, { "text": "tolerate in usernames and companies like", "start": 2774.52, "duration": 4.839 }, { "text": "Gmail could certainly do this as well", "start": 2776.8, "duration": 4.16 }, { "text": "suppose that it's not just that I want", "start": 2779.359, "duration": 4.121 }, { "text": "to exclude at sign suppose that I only", "start": 2780.96, "duration": 5.159 }, { "text": "want to allow for say characters that", "start": 2783.48, "duration": 4.76 }, { "text": "normally appear in words like letters of", "start": 2786.119, "duration": 4.521 }, { "text": "the alphabet A through Z be it uppercase", "start": 2788.24, "duration": 4.8 }, { "text": "or lowercase maybe some numbers in heck", "start": 2790.64, "duration": 3.919 }, { "text": "maybe even an underscore could be", "start": 2793.04, "duration": 4.079 }, { "text": "allowed to well we can use this same", "start": 2794.559, "duration": 4.8 }, { "text": "square bracket syntax to specify a set", "start": 2797.119, "duration": 5.281 }, { "text": "of characters as follows I could do a b", "start": 2799.359, "duration": 6.2 }, { "text": "c d e f g h i j oh my God this is going", "start": 2802.4, "duration": 4.24 }, { "text": "to take forever I'm going to have to", "start": 2805.559, "duration": 3.681 }, { "text": "type out all 26 letters of the alphabet", "start": 2806.64, "duration": 4.719 }, { "text": "both lowercase and uppercase so let me", "start": 2809.24, "duration": 3.76 }, { "text": "stop doing that there's a better way", "start": 2811.359, "duration": 3.76 }, { "text": "already if you want to specify Within", "start": 2813.0, "duration": 5.119 }, { "text": "These square brackets a range of letters", "start": 2815.119, "duration": 5.641 }, { "text": "you can actually just do a hyphen if you", "start": 2818.119, "duration": 6.081 }, { "text": "literally do a hyphen Z in these square", "start": 2820.76, "duration": 5.359 }, { "text": "brackets the computer is going to know", "start": 2824.2, "duration": 4.08 }, { "text": "you mean a through z you do not need to", "start": 2826.119, "duration": 4.761 }, { "text": "type 26 letters of the alphabet if you", "start": 2828.28, "duration": 4.36 }, { "text": "want to include uppercase letters as", "start": 2830.88, "duration": 4.239 }, { "text": "well you just do the same no spaces no", "start": 2832.64, "duration": 5.0 }, { "text": "commas you literally just keep typing a", "start": 2835.119, "duration": 5.881 }, { "text": "through capital Z so I have little a", "start": 2837.64, "duration": 7.0 }, { "text": "hyphen little Z big a hyphen big Z no", "start": 2841.0, "duration": 6.04 }, { "text": "spaces no commas no separators you just", "start": 2844.64, "duration": 4.56 }, { "text": "keep specifying those ranges if I", "start": 2847.04, "duration": 4.72 }, { "text": "additionally want numbers I could do 0 1", "start": 2849.2, "duration": 4.68 }, { "text": "2 3 4 NOP you don't need to type in all", "start": 2851.76, "duration": 4.96 }, { "text": "10 decimal digits you can just say 0", "start": 2853.88, "duration": 5.4 }, { "text": "through n using a hyphen as well and if", "start": 2856.72, "duration": 4.68 }, { "text": "you now want to support underscores as", "start": 2859.28, "duration": 3.64 }, { "text": "well which is pretty common in user", "start": 2861.4, "duration": 3.24 }, { "text": "names for email addresses you can", "start": 2862.92, "duration": 4.24 }, { "text": "literally just type in underscore at the", "start": 2864.64, "duration": 5.16 }, { "text": "at the end notice that all of these", "start": 2867.16, "duration": 5.48 }, { "text": "characters are inside of square brackets", "start": 2869.8, "duration": 5.44 }, { "text": "which just again means here is a set of", "start": 2872.64, "duration": 5.12 }, { "text": "characters that I want to allow I have", "start": 2875.24, "duration": 5.359 }, { "text": "not used a carrot symbol at the", "start": 2877.76, "duration": 4.599 }, { "text": "beginning of this whole thing because I", "start": 2880.599, "duration": 3.921 }, { "text": "don't want to complement it complement", "start": 2882.359, "duration": 4.681 }, { "text": "it with an E not complement it with an i", "start": 2884.52, "duration": 4.12 }, { "text": "I want don't want to complement it by", "start": 2887.04, "duration": 3.84 }, { "text": "making it the opposite I literally want", "start": 2888.64, "duration": 4.919 }, { "text": "to accept only these characters I'm", "start": 2890.88, "duration": 4.0 }, { "text": "going to go ahead and do the same thing", "start": 2893.559, "duration": 4.161 }, { "text": "on the right if I want to require that", "start": 2894.88, "duration": 5.199 }, { "text": "the domain name similarly come from this", "start": 2897.72, "duration": 4.2 }, { "text": "set of characters which admittedly is a", "start": 2900.079, "duration": 3.601 }, { "text": "little too narrow but it's familiar for", "start": 2901.92, "duration": 3.6 }, { "text": "now so we'll keep it simple I'm going to", "start": 2903.68, "duration": 3.84 }, { "text": "go ahead and paste that exact same set", "start": 2905.52, "duration": 5.079 }, { "text": "of characters over there to the right", "start": 2907.52, "duration": 6.28 }, { "text": "and so now it's much more restrictive", "start": 2910.599, "duration": 5.041 }, { "text": "now I'm going to go ahead and run python", "start": 2913.8, "duration": 3.559 }, { "text": "of validate I'm going to test my own", "start": 2915.64, "duration": 3.919 }, { "text": "email address and we're still good I'm", "start": 2917.359, "duration": 3.921 }, { "text": "going to clear my screen and run it once", "start": 2919.559, "duration": 5.321 }, { "text": "more this time trying to break it let me", "start": 2921.28, "duration": 6.72 }, { "text": "go ahead and do something like how about", "start": 2924.88, "duration": 7.64 }, { "text": "davidor maen harvard.edu enter but that", "start": 2928.0, "duration": 7.319 }, { "text": "too is going to be valid but if I do", "start": 2932.52, "duration": 6.319 }, { "text": "something completely wrong again like ma", "start": 2935.319, "duration": 6.841 }, { "text": "harvard.edu that's still going to be", "start": 2938.839, "duration": 5.401 }, { "text": "invalid why because my regular", "start": 2942.16, "duration": 4.12 }, { "text": "expression currently only allows for a", "start": 2944.24, "duration": 4.119 }, { "text": "single at in the middle because", "start": 2946.28, "duration": 4.319 }, { "text": "everything to the left must be alpha", "start": 2948.359, "duration": 5.081 }, { "text": "numeric alphabetical or numeric or an", "start": 2950.599, "duration": 5.441 }, { "text": "underscore the same thing to the right", "start": 2953.44, "duration": 6.24 }, { "text": "followed by the edu now honestly this is", "start": 2956.04, "duration": 5.44 }, { "text": "a regular expression that you might be", "start": 2959.68, "duration": 3.879 }, { "text": "in the habit of typing in the real world", "start": 2961.48, "duration": 4.4 }, { "text": "as in as cryptic as this might look this", "start": 2963.559, "duration": 4.28 }, { "text": "is the world of regular Expressions so", "start": 2965.88, "duration": 3.32 }, { "text": "you'll get more comfortable with this", "start": 2967.839, "duration": 3.96 }, { "text": "syntax over time but thankfully some of", "start": 2969.2, "duration": 5.0 }, { "text": "these patterns are so common that there", "start": 2971.799, "duration": 5.04 }, { "text": "are builtin shortcuts for representing", "start": 2974.2, "duration": 4.96 }, { "text": "some of the same information that is to", "start": 2976.839, "duration": 4.401 }, { "text": "say you don't have to constantly type", "start": 2979.16, "duration": 3.919 }, { "text": "out all of the symbols that you want to", "start": 2981.24, "duration": 3.28 }, { "text": "include because odds are some other", "start": 2983.079, "duration": 3.401 }, { "text": "programmer has had the same problem so", "start": 2984.52, "duration": 3.96 }, { "text": "built into regular Expressions", "start": 2986.48, "duration": 3.839 }, { "text": "themselves are some additional patterns", "start": 2988.48, "duration": 4.56 }, { "text": "you can use and in fact I can go ahead", "start": 2990.319, "duration": 5.52 }, { "text": "and get rid of this entire set a through", "start": 2993.04, "duration": 5.319 }, { "text": "z lowercase A through Z uppercase 0", "start": 2995.839, "duration": 4.601 }, { "text": "through 9 in an underscore and just", "start": 2998.359, "duration": 5.641 }, { "text": "replace it with a single back slw back", "start": 3000.44, "duration": 6.119 }, { "text": "slw in this case represents a word", "start": 3004.0, "duration": 5.28 }, { "text": "character which is commonly known as a", "start": 3006.559, "duration": 6.841 }, { "text": "alpha numeric symbol or the underscore", "start": 3009.28, "duration": 5.88 }, { "text": "as well I'm going to do the same thing", "start": 3013.4, "duration": 3.12 }, { "text": "over here I'm going to highlight the", "start": 3015.16, "duration": 3.639 }, { "text": "entire set of square brackets delete it", "start": 3016.52, "duration": 5.12 }, { "text": "and replace it with a single back slw", "start": 3018.799, "duration": 4.601 }, { "text": "and now I feel like we're making", "start": 3021.64, "duration": 2.919 }, { "text": "progress because even though it's", "start": 3023.4, "duration": 2.84 }, { "text": "cryptic and what if it looked way", "start": 3024.559, "duration": 5.161 }, { "text": "cryptic a little bit ago um and even", "start": 3026.24, "duration": 4.599 }, { "text": "though it would have looked even more", "start": 3029.72, "duration": 3.16 }, { "text": "cryptic a little bit ago now it's at", "start": 3030.839, "duration": 3.881 }, { "text": "least starting to read a little more", "start": 3032.88, "duration": 4.12 }, { "text": "friendly the carrot on the left means", "start": 3034.72, "duration": 3.72 }, { "text": "start matching at the beginning of the", "start": 3037.0, "duration": 5.119 }, { "text": "string back slw means any word character", "start": 3038.44, "duration": 6.359 }, { "text": "the plus means one or more at symbol", "start": 3042.119, "duration": 5.0 }, { "text": "literally then another word character", "start": 3044.799, "duration": 4.841 }, { "text": "one or more then a literal dot then", "start": 3047.119, "duration": 5.2 }, { "text": "literally edu and then match at the very", "start": 3049.64, "duration": 4.76 }, { "text": "end of the string and that's it so", "start": 3052.319, "duration": 3.681 }, { "text": "there's more of these two and we won't", "start": 3054.4, "duration": 4.56 }, { "text": "use them all here but here is a partial", "start": 3056.0, "duration": 5.599 }, { "text": "list of the patterns you can use within", "start": 3058.96, "duration": 5.72 }, { "text": "a regular expression one you have backd", "start": 3061.599, "duration": 5.081 }, { "text": "for any decimal digit decimal digit", "start": 3064.68, "duration": 5.2 }, { "text": "meaning 0 through n commonly done here", "start": 3066.68, "duration": 5.56 }, { "text": "too is if you want to do the opposite of", "start": 3069.88, "duration": 4.56 }, { "text": "that the complement so to speak you can", "start": 3072.24, "duration": 5.0 }, { "text": "do back slash capital D which is", "start": 3074.44, "duration": 5.159 }, { "text": "anything that's not a decimal digit so", "start": 3077.24, "duration": 5.359 }, { "text": "it might be letters and punctuation and", "start": 3079.599, "duration": 6.081 }, { "text": "other symbols as well Meanwhile Back SLS", "start": 3082.599, "duration": 5.2 }, { "text": "means wh space characters like a single", "start": 3085.68, "duration": 4.04 }, { "text": "hit of the space or maybe hitting tab on", "start": 3087.799, "duration": 4.881 }, { "text": "the keyboard that's Whit space back SL", "start": 3089.72, "duration": 5.28 }, { "text": "capital S is the opposite or complement", "start": 3092.68, "duration": 4.72 }, { "text": "of that anything that's not a whit space", "start": 3095.0, "duration": 5.119 }, { "text": "character back slw we've seen a word", "start": 3097.4, "duration": 5.159 }, { "text": "character as well as numbers and the", "start": 3100.119, "duration": 4.161 }, { "text": "underscore and if you want the", "start": 3102.559, "duration": 3.641 }, { "text": "complement or opposite of that you can", "start": 3104.28, "duration": 4.559 }, { "text": "use back SL capital W to give you", "start": 3106.2, "duration": 4.96 }, { "text": "everything but a word character again", "start": 3108.839, "duration": 4.041 }, { "text": "these are just common patterns that so", "start": 3111.16, "duration": 3.24 }, { "text": "many people were presumably using in", "start": 3112.88, "duration": 3.919 }, { "text": "yester year that it's now baked into the", "start": 3114.4, "duration": 4.56 }, { "text": "regular expression syntax so that you", "start": 3116.799, "duration": 5.0 }, { "text": "can more succinctly express your same", "start": 3118.96, "duration": 5.639 }, { "text": "ideas any questions then on this", "start": 3121.799, "duration": 5.8 }, { "text": "approach here where we're now using", "start": 3124.599, "duration": 6.52 }, { "text": "backw to represent my word", "start": 3127.599, "duration": 6.361 }, { "text": "character uh so what I want to ask about", "start": 3131.119, "duration": 4.561 }, { "text": "was the actually the previous approach", "start": 3133.96, "duration": 3.8 }, { "text": "like the square bracket approach could", "start": 3135.68, "duration": 4.72 }, { "text": "we accept like uh lists in there yes", "start": 3137.76, "duration": 4.68 }, { "text": "we'll see this before long but suppose", "start": 3140.4, "duration": 4.679 }, { "text": "you wanted to tolerate not just edu but", "start": 3142.44, "duration": 4.96 }, { "text": "maybe edu or", "start": 3145.079, "duration": 4.48 }, { "text": "you could do this you could introduce", "start": 3147.4, "duration": 4.679 }, { "text": "parentheses and then you can or those", "start": 3149.559, "duration": 6.04 }, { "text": "together I could say Comm or edu I could", "start": 3152.079, "duration": 6.401 }, { "text": "also add in something like in the US or", "start": 3155.599, "duration": 6.441 }, { "text": "gov or net or anything else or org or", "start": 3158.48, "duration": 5.56 }, { "text": "the like and each of the vertical bars", "start": 3162.04, "duration": 4.16 }, { "text": "here means something special it means or", "start": 3164.04, "duration": 4.039 }, { "text": "and the parentheses simply group things", "start": 3166.2, "duration": 4.0 }, { "text": "together formally you have this syntax", "start": 3168.079, "duration": 6.681 }, { "text": "here A or B A or vertical Bar B means a", "start": 3170.2, "duration": 6.52 }, { "text": "has to match or B has to match where A", "start": 3174.76, "duration": 4.48 }, { "text": "and B can be any other patterns you want", "start": 3176.72, "duration": 4.04 }, { "text": "in parentheses you can group those", "start": 3179.24, "duration": 3.599 }, { "text": "things together so just like math you", "start": 3180.76, "duration": 4.96 }, { "text": "can uh combine ideas into one phrase and", "start": 3182.839, "duration": 4.881 }, { "text": "do this thing or the other um and", "start": 3185.72, "duration": 3.399 }, { "text": "there's other syntax as well that we'll", "start": 3187.72, "duration": 3.48 }, { "text": "soon see other questions on these", "start": 3189.119, "duration": 5.48 }, { "text": "regular expressions and this syntax here", "start": 3191.2, "duration": 6.08 }, { "text": "what if we put spaces in the expression", "start": 3194.599, "duration": 5.041 }, { "text": "sure so if you want spaces in there you", "start": 3197.28, "duration": 5.279 }, { "text": "can't use backw alone because that is", "start": 3199.64, "duration": 4.52 }, { "text": "only a word character which is", "start": 3202.559, "duration": 4.04 }, { "text": "alphabetical numerical or the under", "start": 3204.16, "duration": 4.8 }, { "text": "score but you could do this you could go", "start": 3206.599, "duration": 4.601 }, { "text": "back to this approach whereby you use uh", "start": 3208.96, "duration": 3.92 }, { "text": "square brackets and you could say A", "start": 3211.2, "duration": 6.0 }, { "text": "through Z or a through z or 0 through 9", "start": 3212.88, "duration": 6.199 }, { "text": "or underscore or I'm going to hit the", "start": 3217.2, "duration": 3.96 }, { "text": "space bar a single space you can put a", "start": 3219.079, "duration": 3.72 }, { "text": "literal space inside of the square", "start": 3221.16, "duration": 3.36 }, { "text": "brackets which will allow you then to", "start": 3222.799, "duration": 4.721 }, { "text": "detect a space alternatively I could", "start": 3224.52, "duration": 5.88 }, { "text": "still use back slw but I could combine", "start": 3227.52, "duration": 4.76 }, { "text": "it as follows I could say give me a back", "start": 3230.4, "duration": 4.919 }, { "text": "slw or a back slash S because recall", "start": 3232.28, "duration": 5.36 }, { "text": "that back SLS is white space so it's", "start": 3235.319, "duration": 3.721 }, { "text": "even more than a single space it could", "start": 3237.64, "duration": 3.4 }, { "text": "be a tab but by putting those things in", "start": 3239.04, "duration": 4.16 }, { "text": "parentheses now you can match either the", "start": 3241.04, "duration": 4.079 }, { "text": "thing on the left or the thing on the", "start": 3243.2, "duration": 4.639 }, { "text": "right one or more times how about one", "start": 3245.119, "duration": 6.44 }, { "text": "other question on these regular", "start": 3247.839, "duration": 3.72 }, { "text": "Expressions perfect so I was going to", "start": 3251.68, "duration": 6.24 }, { "text": "ask um does the back slw um include a", "start": 3253.64, "duration": 8.04 }, { "text": "DOT uh because no nope it only includes", "start": 3257.92, "duration": 6.48 }, { "text": "letters numbers uh and underscore that", "start": 3261.68, "duration": 5.32 }, { "text": "is it and I was wondering you gave an", "start": 3264.4, "duration": 4.959 }, { "text": "example at the beginning that had uh", "start": 3267.0, "duration": 6.24 }, { "text": "spaces like this is my email so on so um", "start": 3269.359, "duration": 7.081 }, { "text": "I don't think our current version even", "start": 3273.24, "duration": 5.0 }, { "text": "quite quite a long while ago stopped", "start": 3276.44, "duration": 3.84 }, { "text": "accepting it was that because of the", "start": 3278.24, "duration": 3.8 }, { "text": "carrot uh", "start": 3280.28, "duration": 4.72 }, { "text": "or because of something no the reason I", "start": 3282.04, "duration": 5.36 }, { "text": "was handling spaces and other English", "start": 3285.0, "duration": 4.52 }, { "text": "words when I typed out my email address", "start": 3287.4, "duration": 4.919 }, { "text": "as mailin at harvard.edu was because we", "start": 3289.52, "duration": 5.88 }, { "text": "were using initially star or plus which", "start": 3292.319, "duration": 5.0 }, { "text": "is any character", "start": 3295.4, "duration": 4.52 }, { "text": "uh and even after that we said anything", "start": 3297.319, "duration": 5.681 }, { "text": "except the at sign which includes spaces", "start": 3299.92, "duration": 5.639 }, { "text": "only once I started using square", "start": 3303.0, "duration": 5.28 }, { "text": "brackets and a through z and 0 through 9", "start": 3305.559, "duration": 5.321 }, { "text": "and underscore did we finally get to the", "start": 3308.28, "duration": 4.96 }, { "text": "point where we would reject wh space and", "start": 3310.88, "duration": 4.52 }, { "text": "in fact I can run this here let me go", "start": 3313.24, "duration": 4.04 }, { "text": "into the current version of my code in", "start": 3315.4, "duration": 4.199 }, { "text": "VSS code which is using again the back", "start": 3317.28, "duration": 4.88 }, { "text": "WS for word characters let me run python", "start": 3319.599, "duration": 4.881 }, { "text": "of validate and incorrectly type in", "start": 3322.16, "duration": 6.0 }, { "text": "something like my email address is maen", "start": 3324.48, "duration": 6.76 }, { "text": "harvard.edu period which has spaces to", "start": 3328.16, "duration": 5.48 }, { "text": "the left of my username and that is now", "start": 3331.24, "duration": 4.68 }, { "text": "invalid because space is not a word", "start": 3333.64, "duration": 4.28 }, { "text": "character yorgo notes too that", "start": 3335.92, "duration": 4.0 }, { "text": "technically I'm not allowing dots and", "start": 3337.92, "duration": 3.199 }, { "text": "some of you might be thinking wait a", "start": 3339.92, "duration": 4.199 }, { "text": "minute my gmail address has a dot in it", "start": 3341.119, "duration": 4.161 }, { "text": "that's something we're going to still", "start": 3344.119, "duration": 4.2 }, { "text": "have to fix a back slw is not the end", "start": 3345.28, "duration": 5.24 }, { "text": "all here it's just allowing us to", "start": 3348.319, "duration": 4.561 }, { "text": "express our previous solution a little", "start": 3350.52, "duration": 4.96 }, { "text": "more succinctly now one thing we're", "start": 3352.88, "duration": 4.439 }, { "text": "still not handling quite properly is", "start": 3355.48, "duration": 4.879 }, { "text": "uppercase versus lowercase the back slw", "start": 3357.319, "duration": 4.601 }, { "text": "technically does handle lowercase", "start": 3360.359, "duration": 3.401 }, { "text": "letters and uppercase because it's the", "start": 3361.92, "duration": 4.56 }, { "text": "exact same thing as that set from before", "start": 3363.76, "duration": 5.039 }, { "text": "which had little a through little Z and", "start": 3366.48, "duration": 5.119 }, { "text": "big a through big Z but watch this let", "start": 3368.799, "duration": 4.601 }, { "text": "me go ahead and my current form run", "start": 3371.599, "duration": 4.0 }, { "text": "python to validate dopy and just because", "start": 3373.4, "duration": 4.52 }, { "text": "my caps slot key is down maen", "start": 3375.599, "duration": 5.601 }, { "text": "harvard.edu shouting my email address", "start": 3377.92, "duration": 5.679 }, { "text": "it's going to be okay in terms of the ma", "start": 3381.2, "duration": 4.0 }, { "text": "it's going to be okay in terms of the", "start": 3383.599, "duration": 3.841 }, { "text": "Harvard because those are matching the", "start": 3385.2, "duration": 5.159 }, { "text": "back slw which does include lowercase", "start": 3387.44, "duration": 6.24 }, { "text": "and uppercase but I'm about to see", "start": 3390.359, "duration": 8.841 }, { "text": "invalid why why is mail at harvard.edu", "start": 3393.68, "duration": 8.32 }, { "text": "invalid when it's in all caps here even", "start": 3399.2, "duration": 4.32 }, { "text": "though I'm using", "start": 3402.0, "duration": 5.359 }, { "text": "backw yeah so you are asking for the", "start": 3403.52, "duration": 6.76 }, { "text": "domain. edu in lowercase and you're", "start": 3407.359, "duration": 5.841 }, { "text": "typing it in an uppercase exactly I'm", "start": 3410.28, "duration": 5.16 }, { "text": "typing in my email address in all", "start": 3413.2, "duration": 4.2 }, { "text": "uppercase but I'm looking for literally", "start": 3415.44, "duration": 4.2 }, { "text": "edu and as I see you with airpods and so", "start": 3417.4, "duration": 3.84 }, { "text": "many of you with headphones I apologize", "start": 3419.64, "duration": 3.159 }, { "text": "for yelling into my microphone just now", "start": 3421.24, "duration": 3.48 }, { "text": "to make this point but let's see if we", "start": 3422.799, "duration": 5.04 }, { "text": "can't fix that well if my pattern on", "start": 3424.72, "duration": 6.359 }, { "text": "line five is expecting it to be", "start": 3427.839, "duration": 5.2 }, { "text": "lowercase there's actually a few ways I", "start": 3431.079, "duration": 3.641 }, { "text": "can solve this one would be something", "start": 3433.039, "duration": 3.881 }, { "text": "we've seen before I could just force the", "start": 3434.72, "duration": 4.56 }, { "text": "user's input to all lowercase and I", "start": 3436.92, "duration": 4.48 }, { "text": "could put onto the end of my first line", "start": 3439.28, "duration": 4.36 }, { "text": "do lower and actually force it all to", "start": 3441.4, "duration": 4.48 }, { "text": "lowercase alternatively I could do that", "start": 3443.64, "duration": 4.24 }, { "text": "a little later instead of passing in", "start": 3445.88, "duration": 4.12 }, { "text": "email I could pass in the lowercase", "start": 3447.88, "duration": 4.04 }, { "text": "version of email because email addresses", "start": 3450.0, "duration": 3.96 }, { "text": "should in fact be case insensitive so", "start": 3451.92, "duration": 3.76 }, { "text": "that would work too but there's another", "start": 3453.96, "duration": 3.839 }, { "text": "mechanism here which is worth seeing it", "start": 3455.68, "duration": 5.0 }, { "text": "turns out that that function before", "start": 3457.799, "duration": 6.24 }, { "text": "called re. search supports recall a", "start": 3460.68, "duration": 5.48 }, { "text": "third argument as well these so-called", "start": 3464.039, "duration": 4.241 }, { "text": "flags and flags are configuration", "start": 3466.16, "duration": 3.6 }, { "text": "options typically to a function that", "start": 3468.28, "duration": 3.279 }, { "text": "allow you to configure it a little", "start": 3469.76, "duration": 3.76 }, { "text": "differently and how might I go about", "start": 3471.559, "duration": 5.04 }, { "text": "configuring this call to re. search a", "start": 3473.52, "duration": 5.2 }, { "text": "little bit differently in so far as I'm", "start": 3476.599, "duration": 4.401 }, { "text": "currently only passing in two arguments", "start": 3478.72, "duration": 4.16 }, { "text": "well it turns out that some of the flags", "start": 3481.0, "duration": 4.119 }, { "text": "you can pass into this function are", "start": 3482.88, "duration": 4.52 }, { "text": "these it turns out that the regular", "start": 3485.119, "duration": 6.121 }, { "text": "expression library in Python AKA re", "start": 3487.4, "duration": 6.08 }, { "text": "comes with a few built-in variables so", "start": 3491.24, "duration": 4.16 }, { "text": "to speak things that you can think of as", "start": 3493.48, "duration": 5.72 }, { "text": "constants that have meaning to re.", "start": 3495.4, "duration": 6.639 }, { "text": "search and they do so as follows if you", "start": 3499.2, "duration": 5.68 }, { "text": "pass in as a flag re. ignore case what", "start": 3502.039, "duration": 4.961 }, { "text": "re. search is going to do is ignore the", "start": 3504.88, "duration": 3.88 }, { "text": "case of the user's input it can be", "start": 3507.0, "duration": 3.319 }, { "text": "uppercase lower case a combination", "start": 3508.76, "duration": 3.52 }, { "text": "thereof the case is going to be ignored", "start": 3510.319, "duration": 4.201 }, { "text": "it will be treated case insensitively", "start": 3512.28, "duration": 3.519 }, { "text": "and you can do other things too that we", "start": 3514.52, "duration": 3.279 }, { "text": "won't do here but if you want to handle", "start": 3515.799, "duration": 3.8 }, { "text": "the user's input that maybe spans", "start": 3517.799, "duration": 3.56 }, { "text": "multiple lines maybe they didn't just", "start": 3519.599, "duration": 3.76 }, { "text": "type in an email address but an entire", "start": 3521.359, "duration": 4.081 }, { "text": "paragraph of text and you want to match", "start": 3523.359, "duration": 3.801 }, { "text": "different lines of that text that is", "start": 3525.44, "duration": 4.639 }, { "text": "multiple lines another flag is for re.", "start": 3527.16, "duration": 5.72 }, { "text": "multi-line for just that or re doall", "start": 3530.079, "duration": 5.081 }, { "text": "whereby you can con uh you can configure", "start": 3532.88, "duration": 5.36 }, { "text": "the DOT to rep to recognize not just any", "start": 3535.16, "duration": 5.439 }, { "text": "character except new lines but any", "start": 3538.24, "duration": 4.839 }, { "text": "character plus new lines as well but for", "start": 3540.599, "duration": 4.24 }, { "text": "now let me go ahead and just make use of", "start": 3543.079, "duration": 3.841 }, { "text": "this first one let me pass in a third", "start": 3544.839, "duration": 5.361 }, { "text": "argument to re. search which is", "start": 3546.92, "duration": 7.439 }, { "text": "re. uh ignore case let me now rerun the", "start": 3550.2, "duration": 5.839 }, { "text": "program without clearing my screen", "start": 3554.359, "duration": 4.0 }, { "text": "python of validate dopy let me type in", "start": 3556.039, "duration": 4.681 }, { "text": "again in all caps effectively shouting", "start": 3558.359, "duration": 5.841 }, { "text": "maen harvard.edu enter and now it's", "start": 3560.72, "duration": 5.92 }, { "text": "considered valid because I'm telling re.", "start": 3564.2, "duration": 4.359 }, { "text": "search specifically to ignore the case", "start": 3566.64, "duration": 4.24 }, { "text": "of the input and that to here is fine", "start": 3568.559, "duration": 3.961 }, { "text": "and why might I do this approach rather", "start": 3570.88, "duration": 3.8 }, { "text": "than call do lower in one of those other", "start": 3572.52, "duration": 4.12 }, { "text": "locations if I don't actually want to", "start": 3574.68, "duration": 3.76 }, { "text": "change the user's input for whatever", "start": 3576.64, "duration": 3.84 }, { "text": "reason I can still treat it case", "start": 3578.44, "duration": 4.8 }, { "text": "insensitively without actually changing", "start": 3580.48, "duration": 5.76 }, { "text": "the value of that variable itself all", "start": 3583.24, "duration": 5.119 }, { "text": "right any final questions now on this", "start": 3586.24, "duration": 4.24 }, { "text": "validation of email", "start": 3588.359, "duration": 5.881 }, { "text": "addresses uh so the pattern is a string", "start": 3590.48, "duration": 8.0 }, { "text": "right M uh can use an F string you can", "start": 3594.24, "duration": 6.0 }, { "text": "yes you can use an F string so that you", "start": 3598.48, "duration": 3.879 }, { "text": "could plug in for instance the value of", "start": 3600.24, "duration": 4.64 }, { "text": "a variable and pass it into the function", "start": 3602.359, "duration": 4.921 }, { "text": "other questions on this access W", "start": 3604.88, "duration": 4.52 }, { "text": "character could we take it as an input", "start": 3607.28, "duration": 4.48 }, { "text": "from the user technically yes that's not", "start": 3609.4, "duration": 3.8 }, { "text": "a problem we're trying to solve right", "start": 3611.76, "duration": 3.279 }, { "text": "now we want the user to provide literal", "start": 3613.2, "duration": 3.599 }, { "text": "input like their email address not", "start": 3615.039, "duration": 4.241 }, { "text": "necessarily a regular expression but you", "start": 3616.799, "duration": 4.161 }, { "text": "could imagine building software that", "start": 3619.28, "duration": 3.44 }, { "text": "asks the user especially if they're more", "start": 3620.96, "duration": 3.44 }, { "text": "advanced users to type in a regular", "start": 3622.72, "duration": 3.92 }, { "text": "expression for some reason to validate", "start": 3624.4, "duration": 3.76 }, { "text": "something else against that and in fact", "start": 3626.64, "duration": 3.439 }, { "text": "that's what Google's doing if you play", "start": 3628.16, "duration": 3.72 }, { "text": "around with Google forms and create a", "start": 3630.079, "duration": 4.24 }, { "text": "form with response validation and select", "start": 3631.88, "duration": 5.36 }, { "text": "regular expression Google lets you and I", "start": 3634.319, "duration": 4.641 }, { "text": "type in our own regular Expressions", "start": 3637.24, "duration": 3.16 }, { "text": "would be a per which would be a perfect", "start": 3638.96, "duration": 3.44 }, { "text": "example of that all right well let me", "start": 3640.4, "duration": 4.36 }, { "text": "propose that we try to solve one other", "start": 3642.4, "duration": 5.56 }, { "text": "problem here whereby if I go into the", "start": 3644.76, "duration": 5.72 }, { "text": "same version as before which is now", "start": 3647.96, "duration": 4.599 }, { "text": "ignoring case but I type in one of my", "start": 3650.48, "duration": 3.92 }, { "text": "other email addresses let me go ahead", "start": 3652.559, "duration": 4.441 }, { "text": "and run python of validate and this time", "start": 3654.4, "duration": 4.76 }, { "text": "let me type in not maen harvard.edu", "start": 3657.0, "duration": 4.24 }, { "text": "which I use primarily but my another", "start": 3659.16, "duration": 4.28 }, { "text": "email address of mine maen cs50.h", "start": 3661.24, "duration": 4.92 }, { "text": "harvard.edu which forwards to the same", "start": 3663.44, "duration": 5.08 }, { "text": "let me go ahead and hit enter now and", "start": 3666.16, "duration": 5.48 }, { "text": "huh invalid even though I'm pretty sure", "start": 3668.52, "duration": 4.88 }, { "text": "that is in fact my email address well", "start": 3671.64, "duration": 4.32 }, { "text": "let's put our finger on the reason why", "start": 3673.4, "duration": 5.919 }, { "text": "why at the moment is mail at cs50.h", "start": 3675.96, "duration": 6.879 }, { "text": "harvard.edu being considered invalid", "start": 3679.319, "duration": 6.04 }, { "text": "even though I'm pretty sure I send and", "start": 3682.839, "duration": 6.121 }, { "text": "receive email email from that address", "start": 3685.359, "duration": 3.601 }, { "text": "too why might that be because there is a", "start": 3689.599, "duration": 9.121 }, { "text": "DOT that has come after the ad symbol", "start": 3693.48, "duration": 9.0 }, { "text": "exactly there's a DOT after my cs50 and", "start": 3698.72, "duration": 5.52 }, { "text": "I'm not expecting any dots there I'm", "start": 3702.48, "duration": 4.119 }, { "text": "expecting only again word characters", "start": 3704.24, "duration": 5.92 }, { "text": "which is a through z 0-9 and underscore", "start": 3706.599, "duration": 5.881 }, { "text": "so I'm going to have to retool here but", "start": 3710.16, "duration": 4.04 }, { "text": "how could I go about doing this well it", "start": 3712.48, "duration": 4.04 }, { "text": "turns out theoretically there could be", "start": 3714.2, "duration": 3.839 }, { "text": "other email addresses even though they'd", "start": 3716.52, "duration": 3.4 }, { "text": "be getting a little excessively long for", "start": 3718.039, "duration": 4.881 }, { "text": "instance mailin at something. cs50.h", "start": 3719.92, "duration": 4.84 }, { "text": "harvard.edu which is not technically", "start": 3722.92, "duration": 4.119 }, { "text": "exist but it could you can have of", "start": 3724.76, "duration": 4.2 }, { "text": "course multiple dots in a domain name", "start": 3727.039, "duration": 3.76 }, { "text": "like we see here wouldn't it be nice if", "start": 3728.96, "duration": 4.079 }, { "text": "we could handle that as well well let me", "start": 3730.799, "duration": 4.48 }, { "text": "propose that we modify my regular", "start": 3733.039, "duration": 4.921 }, { "text": "expression as follows it turns out that", "start": 3735.279, "duration": 5.52 }, { "text": "you can group ideas together and you can", "start": 3737.96, "duration": 5.56 }, { "text": "not only ask whether or not this pattern", "start": 3740.799, "duration": 5.721 }, { "text": "matches or this one using syntax like a", "start": 3743.52, "duration": 6.319 }, { "text": "vertical Bar B which means either A or B", "start": 3746.52, "duration": 5.68 }, { "text": "you can also group things together and", "start": 3749.839, "duration": 4.44 }, { "text": "then apply some other operator to them", "start": 3752.2, "duration": 4.2 }, { "text": "as well in fact let me go back to VSS", "start": 3754.279, "duration": 4.201 }, { "text": "code here and let me propose that if I", "start": 3756.4, "duration": 5.639 }, { "text": "want to tolerate a subdomain like cs50", "start": 3758.48, "duration": 6.559 }, { "text": "that may or may not be there let me go", "start": 3762.039, "duration": 5.121 }, { "text": "ahead and change it as follows I could", "start": 3765.039, "duration": 4.08 }, { "text": "naively do this if I want to support", "start": 3767.16, "duration": 4.399 }, { "text": "subdomains I could say well let's allow", "start": 3769.119, "duration": 5.401 }, { "text": "for otherw characters plus and then a", "start": 3771.559, "duration": 4.921 }, { "text": "literal Dot and and notice I'll", "start": 3774.52, "duration": 4.0 }, { "text": "highlight in blue here what I've just", "start": 3776.48, "duration": 4.119 }, { "text": "added everything else is the same but", "start": 3778.52, "duration": 5.039 }, { "text": "I'm now adding room for another sequence", "start": 3780.599, "duration": 5.52 }, { "text": "of one or more word characters and then", "start": 3783.559, "duration": 7.0 }, { "text": "a literal dot so this now I think if I", "start": 3786.119, "duration": 6.841 }, { "text": "rerun python of validate will work for", "start": 3790.559, "duration": 6.121 }, { "text": "maen cs50.h harvard.edu enter", "start": 3792.96, "duration": 5.76 }, { "text": "unfortunately does anyone see where this", "start": 3796.68, "duration": 4.639 }, { "text": "is going let me rerun python of validate", "start": 3798.72, "duration": 4.8 }, { "text": "dopy and type in as I keep doing maen at", "start": 3801.319, "duration": 4.081 }, { "text": "harvard.edu which up until now has kept", "start": 3803.52, "duration": 4.88 }, { "text": "working despite all of my changes but", "start": 3805.4, "duration": 6.879 }, { "text": "now finally I've broken my own email", "start": 3808.4, "duration": 6.8 }, { "text": "address so logically what's the solution", "start": 3812.279, "duration": 4.481 }, { "text": "here well there's a bunch of ways we", "start": 3815.2, "duration": 3.32 }, { "text": "could solve this I could maybe start", "start": 3816.76, "duration": 3.76 }, { "text": "using two regular expressions and", "start": 3818.52, "duration": 4.279 }, { "text": "support you uh email addresses of the", "start": 3820.52, "duration": 7.279 }, { "text": "form username at domain. TLD or username", "start": 3822.799, "duration": 8.401 }, { "text": "at subdomain dod. TLD where TLD just", "start": 3827.799, "duration": 6.24 }, { "text": "means top level domain like edu or I", "start": 3831.2, "duration": 4.76 }, { "text": "could maybe just modify this one cuz I'd", "start": 3834.039, "duration": 4.481 }, { "text": "prefer not to have like two uh regular", "start": 3835.96, "duration": 5.04 }, { "text": "expressions or one that's twice as big", "start": 3838.52, "duration": 5.24 }, { "text": "why don't I just specify to re. search", "start": 3841.0, "duration": 5.76 }, { "text": "that part of this pattern is optional", "start": 3843.76, "duration": 6.039 }, { "text": "what was the symbol we saw earlier that", "start": 3846.76, "duration": 5.079 }, { "text": "allows you to specify that the thing", "start": 3849.799, "duration": 5.641 }, { "text": "before it is technically optional the", "start": 3851.839, "duration": 5.801 }, { "text": "straight bar we are using the Straight", "start": 3855.44, "duration": 3.359 }, { "text": "bar as", "start": 3857.64, "duration": 4.199 }, { "text": "a optional make the opt the argument", "start": 3858.799, "duration": 5.361 }, { "text": "optional so we could we could use a", "start": 3861.839, "duration": 4.801 }, { "text": "vertical bar and some parth es and say", "start": 3864.16, "duration": 4.76 }, { "text": "either there's something here or there's", "start": 3866.64, "duration": 4.36 }, { "text": "nothing we could do that in parentheses", "start": 3868.92, "duration": 3.6 }, { "text": "but I think there's actually an even", "start": 3871.0, "duration": 4.48 }, { "text": "easier way uh actually is a question", "start": 3872.52, "duration": 6.0 }, { "text": "mark indeed question mark think back to", "start": 3875.48, "duration": 5.119 }, { "text": "this summary here of our first set of", "start": 3878.52, "duration": 5.0 }, { "text": "symbols whereby we had not just Dot and", "start": 3880.599, "duration": 5.281 }, { "text": "star and plus but also a question mark", "start": 3883.52, "duration": 4.839 }, { "text": "which means literally zero or one", "start": 3885.88, "duration": 4.36 }, { "text": "repetitions which effectively means", "start": 3888.359, "duration": 4.841 }, { "text": "optional it's either there one or it's", "start": 3890.24, "duration": 6.28 }, { "text": "not zero now how can I translate to that", "start": 3893.2, "duration": 5.44 }, { "text": "to this code here well let me go ahead", "start": 3896.52, "duration": 5.12 }, { "text": "and Surround this part of my pattern", "start": 3898.64, "duration": 5.399 }, { "text": "with parentheses which doesn't mean I", "start": 3901.64, "duration": 4.28 }, { "text": "want literally a parenthesis in the", "start": 3904.039, "duration": 4.121 }, { "text": "user's input I just want to group these", "start": 3905.92, "duration": 4.679 }, { "text": "characters together and in fact this now", "start": 3908.16, "duration": 4.199 }, { "text": "will still work I've only added", "start": 3910.599, "duration": 3.52 }, { "text": "parentheses around the new part for the", "start": 3912.359, "duration": 3.96 }, { "text": "subdomain let me run python of validate", "start": 3914.119, "duration": 5.321 }, { "text": "dopy let me run ma cs50.h harvard.edu", "start": 3916.319, "duration": 5.921 }, { "text": "enter that's still valid but to be clear", "start": 3919.44, "duration": 5.28 }, { "text": "if I rerun it again for maen harvard.edu", "start": 3922.24, "duration": 6.559 }, { "text": "that is still invalid but not if I go in", "start": 3924.72, "duration": 6.599 }, { "text": "here and say after the parentheses which", "start": 3928.799, "duration": 5.641 }, { "text": "now is one logical unit it's one big", "start": 3931.319, "duration": 6.121 }, { "text": "group of ideas together I add a single", "start": 3934.44, "duration": 6.04 }, { "text": "question mark there this will now tell", "start": 3937.44, "duration": 5.56 }, { "text": "re. search that that whole thing in", "start": 3940.48, "duration": 5.76 }, { "text": "parentheses can either be there once or", "start": 3943.0, "duration": 6.44 }, { "text": "be there not at all zero times so what", "start": 3946.24, "duration": 5.319 }, { "text": "does this translate into when I run it", "start": 3949.44, "duration": 4.04 }, { "text": "well let me go ahead and rerun it with", "start": 3951.559, "duration": 5.161 }, { "text": "Ma at cs50.h harvard. you so that the", "start": 3953.48, "duration": 6.28 }, { "text": "subdomain is there that works as before", "start": 3956.72, "duration": 4.72 }, { "text": "let me clear my screen and run it again", "start": 3959.76, "duration": 4.64 }, { "text": "python validate with Ma at harvard.edu", "start": 3961.44, "duration": 5.639 }, { "text": "which used to work then broke is are we", "start": 3964.4, "duration": 5.76 }, { "text": "back in business now we are that's now", "start": 3967.079, "duration": 6.28 }, { "text": "valid again questions now on this", "start": 3970.16, "duration": 5.639 }, { "text": "approach where we've use not just the", "start": 3973.359, "duration": 4.841 }, { "text": "question mark But the parentheses as", "start": 3975.799, "duration": 4.48 }, { "text": "well okay yeah you said he works for", "start": 3978.2, "duration": 5.079 }, { "text": "zero or one repetition what if you have", "start": 3980.279, "duration": 5.921 }, { "text": "more what if you have more that's okay", "start": 3983.279, "duration": 6.241 }, { "text": "that's where you could do star star is", "start": 3986.2, "duration": 5.72 }, { "text": "zero or more which gives you all the", "start": 3989.52, "duration": 5.599 }, { "text": "flexibility in the world yeah so I was", "start": 3991.92, "duration": 5.76 }, { "text": "just asking that uh uh with question", "start": 3995.119, "duration": 5.601 }, { "text": "mark there's only one repetition allow", "start": 3997.68, "duration": 5.28 }, { "text": "it means zero or one repetition so it's", "start": 4000.72, "duration": 5.599 }, { "text": "either not there or it is there and so", "start": 4002.96, "duration": 5.319 }, { "text": "that's why this pattern now if I go back", "start": 4006.319, "duration": 3.641 }, { "text": "to my code even though again it", "start": 4008.279, "duration": 3.721 }, { "text": "admittedly looks cryptic let me", "start": 4009.96, "duration": 4.56 }, { "text": "highlight everything after the at sign", "start": 4012.0, "duration": 5.079 }, { "text": "and before the dollar sign sign this now", "start": 4014.52, "duration": 4.88 }, { "text": "represents a domain name like", "start": 4017.079, "duration": 5.96 }, { "text": "harvard.edu or a subdomain within the", "start": 4019.4, "duration": 6.32 }, { "text": "domain name why well this part to the", "start": 4023.039, "duration": 5.721 }, { "text": "right is the same as always backw plus", "start": 4025.72, "duration": 5.92 }, { "text": "means something like Harvard or Yale", "start": 4028.76, "duration": 6.48 }, { "text": "back.edu means literally doedu so the", "start": 4031.64, "duration": 6.24 }, { "text": "new part is this in parentheses I have", "start": 4035.24, "duration": 7.119 }, { "text": "another set of backw plus back SL do now", "start": 4037.88, "duration": 6.88 }, { "text": "but it's all in parentheses I'm now", "start": 4042.359, "duration": 4.281 }, { "text": "having any question mark right after", "start": 4044.76, "duration": 3.44 }, { "text": "that which means that whole thing in", "start": 4046.64, "duration": 4.52 }, { "text": "parentheses either can be there or it", "start": 4048.2, "duration": 4.72 }, { "text": "can't be there it's either of those that", "start": 4051.16, "duration": 4.48 }, { "text": "are acceptable so a question mark", "start": 4052.92, "duration": 5.24 }, { "text": "effectively makes something optional it", "start": 4055.64, "duration": 4.24 }, { "text": "would not be correct to remove the", "start": 4058.16, "duration": 3.919 }, { "text": "parentheses because what would this mean", "start": 4059.88, "duration": 4.479 }, { "text": "if I remove the parentheses that would", "start": 4062.079, "duration": 5.401 }, { "text": "mean that only this dot is optional", "start": 4064.359, "duration": 4.48 }, { "text": "which isn't really what we want to", "start": 4067.48, "duration": 5.16 }, { "text": "express I want the subdomain like cs50", "start": 4068.839, "duration": 5.921 }, { "text": "and the additional dot to be what's", "start": 4072.64, "duration": 3.919 }, { "text": "there or not there there how about one", "start": 4074.76, "duration": 4.88 }, { "text": "other question on rexus here can they", "start": 4076.559, "duration": 6.04 }, { "text": "use this for the usernames absolutely we", "start": 4079.64, "duration": 4.399 }, { "text": "still have other problems right we're", "start": 4082.599, "duration": 3.081 }, { "text": "not solving all of the problems today", "start": 4084.039, "duration": 4.28 }, { "text": "just yet but absolutely right now we are", "start": 4085.68, "duration": 5.0 }, { "text": "not letting you have a period in your", "start": 4088.319, "duration": 3.96 }, { "text": "username and again some of you with", "start": 4090.68, "duration": 3.599 }, { "text": "Gmail accounts or other accounts you", "start": 4092.279, "duration": 3.441 }, { "text": "probably have not just underscores", "start": 4094.279, "duration": 2.56 }, { "text": "numbers and letters you might have", "start": 4095.72, "duration": 4.079 }, { "text": "periods too well we could fix that not", "start": 4096.839, "duration": 5.241 }, { "text": "using question mark here per se but now", "start": 4099.799, "duration": 4.0 }, { "text": "that we have these parentheses at our", "start": 4102.08, "duration": 4.84 }, { "text": "disposal what I could do is this I could", "start": 4103.799, "duration": 6.56 }, { "text": "use parentheses to surround the back slw", "start": 4106.92, "duration": 5.16 }, { "text": "to say any word character which is the", "start": 4110.359, "duration": 4.081 }, { "text": "same thing again as a letter or a number", "start": 4112.08, "duration": 5.159 }, { "text": "or an underscore but I could also or in", "start": 4114.44, "duration": 6.04 }, { "text": "using a vertical bar something else like", "start": 4117.239, "duration": 6.0 }, { "text": "a literal dot now a literal dot needs to", "start": 4120.48, "duration": 4.96 }, { "text": "be escaped otherwise it represents any", "start": 4123.239, "duration": 3.881 }, { "text": "character which would be a regression a", "start": 4125.44, "duration": 4.08 }, { "text": "step back but now notice what I've done", "start": 4127.12, "duration": 5.639 }, { "text": "in parentheses I'm telling re. search", "start": 4129.52, "duration": 5.239 }, { "text": "that those first few characters in your", "start": 4132.759, "duration": 4.161 }, { "text": "email address that is your username has", "start": 4134.759, "duration": 5.361 }, { "text": "to be a word character Like A through Z", "start": 4136.92, "duration": 5.56 }, { "text": "uppercase or lowercase or 0 through 9 or", "start": 4140.12, "duration": 5.599 }, { "text": "an underscore or a literal dot we could", "start": 4142.48, "duration": 5.04 }, { "text": "do this differently too I could get rid", "start": 4145.719, "duration": 4.361 }, { "text": "of the parentheses and the or and I", "start": 4147.52, "duration": 4.56 }, { "text": "could just use a set of characters I", "start": 4150.08, "duration": 5.119 }, { "text": "could again manually say a through z a", "start": 4152.08, "duration": 7.079 }, { "text": "through z 0 through 9 underscore and", "start": 4155.199, "duration": 5.921 }, { "text": "then I could do a literal dot with a", "start": 4159.159, "duration": 4.56 }, { "text": "back slash period and now I technically", "start": 4161.12, "duration": 4.039 }, { "text": "don't even need the uppercase because", "start": 4163.719, "duration": 2.921 }, { "text": "I'm already telling the computer to", "start": 4165.159, "duration": 3.52 }, { "text": "ignore case I can just pick one or the", "start": 4166.64, "duration": 4.119 }, { "text": "other which one is better is really up", "start": 4168.679, "duration": 3.48 }, { "text": "to you whichever one you think is more", "start": 4170.759, "duration": 3.92 }, { "text": "readable would generally be the better", "start": 4172.159, "duration": 5.361 }, { "text": "design all right let me propose that I", "start": 4174.679, "duration": 6.321 }, { "text": "rewind this in time to where we left off", "start": 4177.52, "duration": 6.52 }, { "text": "which was here and let me propose that", "start": 4181.0, "duration": 5.0 }, { "text": "there are indeed still limitations of", "start": 4184.04, "duration": 4.52 }, { "text": "this solution not just with the username", "start": 4186.0, "duration": 3.92 }, { "text": "not just with the domain name we're", "start": 4188.56, "duration": 3.52 }, { "text": "still being a little too restrictive so", "start": 4189.92, "duration": 4.0 }, { "text": "would you like to see the official", "start": 4192.08, "duration": 3.32 }, { "text": "regular expression that at least", "start": 4193.92, "duration": 3.84 }, { "text": "browsers use nowadays whenever you type", "start": 4195.4, "duration": 4.24 }, { "text": "in an email address to a web form and", "start": 4197.76, "duration": 4.479 }, { "text": "the web form the browser tells you yes", "start": 4199.64, "duration": 4.24 }, { "text": "or no your email address is", "start": 4202.239, "duration": 6.48 }, { "text": "syntactically valid ready ready here is", "start": 4203.88, "duration": 7.839 }, { "text": "and this isn't even officially the right", "start": 4208.719, "duration": 5.121 }, { "text": "regular expression it's a simplified", "start": 4211.719, "duration": 3.921 }, { "text": "version that browsers use because it", "start": 4213.84, "duration": 4.44 }, { "text": "catches most mistakes but not all here", "start": 4215.64, "duration": 6.44 }, { "text": "we go this is the regular expression for", "start": 4218.28, "duration": 6.48 }, { "text": "a valid email address at least as", "start": 4222.08, "duration": 5.84 }, { "text": "browsers nowadays Implement them now", "start": 4224.76, "duration": 6.24 }, { "text": "it's crazy cryptic at first glance but", "start": 4227.92, "duration": 5.2 }, { "text": "not and it's wrapping onto many lines", "start": 4231.0, "duration": 4.48 }, { "text": "but it's just one pattern but just", "start": 4233.12, "duration": 5.32 }, { "text": "notice the now familiar symbols there is", "start": 4235.48, "duration": 5.32 }, { "text": "the carrot symbol at the very top there", "start": 4238.44, "duration": 5.0 }, { "text": "is the dollar sign at the very end there", "start": 4240.8, "duration": 4.64 }, { "text": "is a square bracket over here and then", "start": 4243.44, "duration": 3.84 }, { "text": "some of these ranges plus other", "start": 4245.44, "duration": 3.84 }, { "text": "characters turns out you don't normally", "start": 4247.28, "duration": 3.879 }, { "text": "see these characters in email addresses", "start": 4249.28, "duration": 3.399 }, { "text": "it looks like you're swearing at someone", "start": 4251.159, "duration": 3.601 }, { "text": "in their username but they're valid", "start": 4252.679, "duration": 4.081 }, { "text": "characters they're valid officially that", "start": 4254.76, "duration": 3.479 }, { "text": "doesn't mean that Gmail is going to", "start": 4256.76, "duration": 4.0 }, { "text": "allow you to put dollar signs and other", "start": 4258.239, "duration": 4.241 }, { "text": "punctuation in your username but", "start": 4260.76, "duration": 4.08 }, { "text": "officially some servers might allow that", "start": 4262.48, "duration": 4.36 }, { "text": "so if you really want to validate a", "start": 4264.84, "duration": 4.16 }, { "text": "user's email address you would actually", "start": 4266.84, "duration": 4.56 }, { "text": "come up with or copy paste something", "start": 4269.0, "duration": 5.0 }, { "text": "like this but honestly this looks so", "start": 4271.4, "duration": 4.4 }, { "text": "cryptic and if you were to type it out", "start": 4274.0, "duration": 3.96 }, { "text": "manually you are so likely to make a", "start": 4275.8, "duration": 4.399 }, { "text": "mistake what's the better solution here", "start": 4277.96, "duration": 5.239 }, { "text": "instead this is where P past week's", "start": 4280.199, "duration": 5.641 }, { "text": "libraries are your friend sure someone", "start": 4283.199, "duration": 5.121 }, { "text": "else on the internet a programmer more", "start": 4285.84, "duration": 4.839 }, { "text": "experienced than you even has come up", "start": 4288.32, "duration": 5.12 }, { "text": "with code that validates email addresses", "start": 4290.679, "duration": 4.681 }, { "text": "properly using this regular expression", "start": 4293.44, "duration": 3.52 }, { "text": "or even something more sophisticated", "start": 4295.36, "duration": 3.52 }, { "text": "than that so generally if the problem at", "start": 4296.96, "duration": 4.4 }, { "text": "hand is to validate input that is pretty", "start": 4298.88, "duration": 4.96 }, { "text": "conventional an email address a URL", "start": 4301.36, "duration": 3.839 }, { "text": "something where there's an official", "start": 4303.84, "duration": 3.799 }, { "text": "definition that's independent of you", "start": 4305.199, "duration": 5.241 }, { "text": "yourself find a popular library that", "start": 4307.639, "duration": 5.281 }, { "text": "you're comfortable using and use it in", "start": 4310.44, "duration": 4.56 }, { "text": "your code to validate email addresses", "start": 4312.92, "duration": 4.64 }, { "text": "this is not a wheel necessarily that you", "start": 4315.0, "duration": 4.719 }, { "text": "yourself should invent we've used email", "start": 4317.56, "duration": 4.2 }, { "text": "addresses though to iteratively start", "start": 4319.719, "duration": 4.081 }, { "text": "from something simple too simple and", "start": 4321.76, "duration": 3.919 }, { "text": "build on top of that so you could", "start": 4323.8, "duration": 3.399 }, { "text": "certainly imagine using regular", "start": 4325.679, "duration": 2.921 }, { "text": "Expressions still to validate things", "start": 4327.199, "duration": 3.52 }, { "text": "that aren't email addresses but are data", "start": 4328.6, "duration": 4.599 }, { "text": "that are important to you so we at least", "start": 4330.719, "duration": 4.721 }, { "text": "now have these building blocks now", "start": 4333.199, "duration": 3.801 }, { "text": "besides the regular Expressions", "start": 4335.44, "duration": 2.96 }, { "text": "themselves it turns out there's other", "start": 4337.0, "duration": 3.88 }, { "text": "functions in Python's re library for", "start": 4338.4, "duration": 4.36 }, { "text": "regular Expressions among them is this", "start": 4340.88, "duration": 3.68 }, { "text": "function here re. match which is", "start": 4342.76, "duration": 4.28 }, { "text": "actually very similar to re. search", "start": 4344.56, "duration": 4.24 }, { "text": "except you don't have to specify the", "start": 4347.04, "duration": 3.32 }, { "text": "carrot symbol at the very beginning of", "start": 4348.8, "duration": 3.28 }, { "text": "your Rex if you want to match from the", "start": 4350.36, "duration": 4.6 }, { "text": "start of a string re. match by Design", "start": 4352.08, "duration": 4.96 }, { "text": "will automatically start matching from", "start": 4354.96, "duration": 3.96 }, { "text": "the start of the string for you similar", "start": 4357.04, "duration": 4.28 }, { "text": "in spirit is re. full match which does", "start": 4358.92, "duration": 4.12 }, { "text": "the same thing but not only matches at", "start": 4361.32, "duration": 3.2 }, { "text": "the start of the string but the end of", "start": 4363.04, "duration": 3.32 }, { "text": "the string so that you too don't need to", "start": 4364.52, "duration": 4.24 }, { "text": "type in the carrot symbol or the dollar", "start": 4366.36, "duration": 4.64 }, { "text": "sign as well but let's go ahead and", "start": 4368.76, "duration": 4.32 }, { "text": "transition back now to some actual code", "start": 4371.0, "duration": 3.76 }, { "text": "whereby we solve a different problem in", "start": 4373.08, "duration": 3.88 }, { "text": "spirit rather than just validate the", "start": 4374.76, "duration": 4.04 }, { "text": "user's input and make sure it looks the", "start": 4376.96, "duration": 3.84 }, { "text": "way we want let's just assume that the", "start": 4378.8, "duration": 3.879 }, { "text": "users are not going to type in data", "start": 4380.8, "duration": 3.839 }, { "text": "exactly as we want and so we're going to", "start": 4382.679, "duration": 3.801 }, { "text": "have to clean up their input this", "start": 4384.639, "duration": 3.641 }, { "text": "happens so often when you're using like", "start": 4386.48, "duration": 4.28 }, { "text": "a Google form or Office 365 form or", "start": 4388.28, "duration": 4.72 }, { "text": "anything else to collect user input no", "start": 4390.76, "duration": 4.56 }, { "text": "matter what your form question says your", "start": 4393.0, "duration": 4.12 }, { "text": "users are not necessarily going to", "start": 4395.32, "duration": 3.48 }, { "text": "follow those directions they might go", "start": 4397.12, "duration": 3.079 }, { "text": "ahead and type in something that's a", "start": 4398.8, "duration": 3.32 }, { "text": "little differently formatted than you", "start": 4400.199, "duration": 3.921 }, { "text": "might like now you could certainly go", "start": 4402.12, "duration": 4.64 }, { "text": "through the results and download a CSV", "start": 4404.12, "duration": 4.36 }, { "text": "or open the Google spreadsheet or", "start": 4406.76, "duration": 3.76 }, { "text": "equivalent in Excel and just clean up", "start": 4408.48, "duration": 4.12 }, { "text": "all the data manually but if you've got", "start": 4410.52, "duration": 4.199 }, { "text": "lots of submissions dozens hundreds", "start": 4412.6, "duration": 4.76 }, { "text": "thousands of rows in your data set doing", "start": 4414.719, "duration": 4.48 }, { "text": "things manually might not be very fun it", "start": 4417.36, "duration": 3.56 }, { "text": "might be much more effective to write", "start": 4419.199, "duration": 4.52 }, { "text": "code as in Python that can allow you to", "start": 4420.92, "duration": 5.44 }, { "text": "clean up that data and any future data", "start": 4423.719, "duration": 5.841 }, { "text": "as well so let me propose that we go", "start": 4426.36, "duration": 5.359 }, { "text": "ahead here and close validate dopy and", "start": 4429.56, "duration": 3.88 }, { "text": "let's go ahead and create a new program", "start": 4431.719, "duration": 4.041 }, { "text": "alog together called format. Pi the goal", "start": 4433.44, "duration": 4.68 }, { "text": "of which is to reformat the user's input", "start": 4435.76, "duration": 4.64 }, { "text": "in the format we expect I'm going to go", "start": 4438.12, "duration": 5.28 }, { "text": "ahead and run code of format. piy and", "start": 4440.4, "duration": 4.759 }, { "text": "let's suppose that the data we're going", "start": 4443.4, "duration": 4.56 }, { "text": "to reformat is the user's name so not", "start": 4445.159, "duration": 5.04 }, { "text": "email address but name this time and", "start": 4447.96, "duration": 3.48 }, { "text": "we're going to hope that they type in", "start": 4450.199, "duration": 4.52 }, { "text": "their name properly like David ma but", "start": 4451.44, "duration": 4.799 }, { "text": "some users might be in the habit for", "start": 4454.719, "duration": 3.161 }, { "text": "whatever reason of typing their name", "start": 4456.239, "duration": 3.681 }, { "text": "backwards if you will with a comma such", "start": 4457.88, "duration": 6.72 }, { "text": "as ma comma David instead now it's fine", "start": 4459.92, "duration": 6.6 }, { "text": "because both both are clearly as", "start": 4464.6, "duration": 3.8 }, { "text": "readable to the human but if you want to", "start": 4466.52, "duration": 4.0 }, { "text": "standardize how those names are stored", "start": 4468.4, "duration": 4.56 }, { "text": "in your system perhaps a database or CSV", "start": 4470.52, "duration": 4.24 }, { "text": "file or something else it would be nice", "start": 4472.96, "duration": 3.96 }, { "text": "to at least standardize or canonicalize", "start": 4474.76, "duration": 3.8 }, { "text": "the format in which you're storing your", "start": 4476.92, "duration": 3.759 }, { "text": "data so that if you print out the user's", "start": 4478.56, "duration": 4.119 }, { "text": "name it's always the same format David", "start": 4480.679, "duration": 4.761 }, { "text": "men and there's no commas or backwards", "start": 4482.679, "duration": 5.401 }, { "text": "to it so let's go ahead and do something", "start": 4485.44, "duration": 4.04 }, { "text": "familiar let's go ahead and give myself", "start": 4488.08, "duration": 3.599 }, { "text": "a variable called name and set it equal", "start": 4489.48, "duration": 3.96 }, { "text": "to the return value of input asking the", "start": 4491.679, "duration": 3.96 }, { "text": "user as we've done many times what's", "start": 4493.44, "duration": 4.12 }, { "text": "your name question mark I'm going to go", "start": 4495.639, "duration": 3.721 }, { "text": "ahead and proactively at least clean up", "start": 4497.56, "duration": 4.119 }, { "text": "some messiness as we keep doing here by", "start": 4499.36, "duration": 3.72 }, { "text": "just stripping off any leading or", "start": 4501.679, "duration": 2.881 }, { "text": "trailing whites space just in case the", "start": 4503.08, "duration": 3.559 }, { "text": "user accidentally hits the space bar we", "start": 4504.56, "duration": 4.44 }, { "text": "don't want that ultimately in our data", "start": 4506.639, "duration": 4.721 }, { "text": "set and now let me go ahead and do this", "start": 4509.0, "duration": 3.76 }, { "text": "as we've done before let me just go", "start": 4511.36, "duration": 3.24 }, { "text": "ahead quickly and print out just to make", "start": 4512.76, "duration": 4.28 }, { "text": "sure I'm off to the right start hello", "start": 4514.6, "duration": 4.559 }, { "text": "and then in curly braces name so making", "start": 4517.04, "duration": 5.159 }, { "text": "an F string to format hello comma name", "start": 4519.159, "duration": 4.401 }, { "text": "now let me go ahead and clear my screen", "start": 4522.199, "duration": 3.921 }, { "text": "and run python a format up Pi let me", "start": 4523.56, "duration": 4.36 }, { "text": "behave and type in my name as I normally", "start": 4526.12, "duration": 4.519 }, { "text": "would David space ma enter and I think", "start": 4527.92, "duration": 4.88 }, { "text": "the output looks pretty good it looks as", "start": 4530.639, "duration": 4.52 }, { "text": "expected grammatically let me now go", "start": 4532.8, "duration": 4.72 }, { "text": "ahead though and play this game again", "start": 4535.159, "duration": 3.601 }, { "text": "but this time maybe because I'm not", "start": 4537.52, "duration": 2.52 }, { "text": "thinking or I'm just in the habit of", "start": 4538.76, "duration": 3.879 }, { "text": "doing last name comma first I do mein", "start": 4540.04, "duration": 5.4 }, { "text": "comma David and hit enter all right well", "start": 4542.639, "duration": 5.241 }, { "text": "this now is is weird even though the", "start": 4545.44, "duration": 4.239 }, { "text": "program is just spitting out exactly", "start": 4547.88, "duration": 4.319 }, { "text": "what I typed in arguably this is not", "start": 4549.679, "duration": 4.241 }, { "text": "close to correct at least grammatically", "start": 4552.199, "duration": 4.921 }, { "text": "it should really say hello David ma now", "start": 4553.92, "duration": 4.759 }, { "text": "maybe I could have some if conditions", "start": 4557.12, "duration": 3.119 }, { "text": "and I could just reject the users's", "start": 4558.679, "duration": 3.641 }, { "text": "input if they type a comma or get their", "start": 4560.239, "duration": 4.121 }, { "text": "names backwards somehow but that's going", "start": 4562.32, "duration": 4.359 }, { "text": "to be uh too little too late if the user", "start": 4564.36, "duration": 4.72 }, { "text": "has already submitted a form online and", "start": 4566.679, "duration": 4.601 }, { "text": "I already have the data and now I need", "start": 4569.08, "duration": 3.84 }, { "text": "to go in and clean it up and it's not", "start": 4571.28, "duration": 3.32 }, { "text": "going to be fun to go through manually", "start": 4572.92, "duration": 3.64 }, { "text": "in Google spreadsheets or apple numbers", "start": 4574.6, "duration": 4.76 }, { "text": "or Microsoft Excel and manually fix a", "start": 4576.56, "duration": 4.52 }, { "text": "lot of people's names to get rid of the", "start": 4579.36, "duration": 3.56 }, { "text": "commas and move the first name before", "start": 4581.08, "duration": 5.0 }, { "text": "the last as is conventional in the us so", "start": 4582.92, "duration": 5.0 }, { "text": "let's do this it could be a little", "start": 4586.08, "duration": 3.76 }, { "text": "fragile but let's like let's start to", "start": 4587.92, "duration": 2.92 }, { "text": "express ourselves a little", "start": 4589.84, "duration": 3.6 }, { "text": "programmatically here and ask this if", "start": 4590.84, "duration": 6.0 }, { "text": "there is a comma in the person's name", "start": 4593.44, "duration": 5.32 }, { "text": "which is pythonic I'm just asking the", "start": 4596.84, "duration": 4.04 }, { "text": "question is this shorter string in this", "start": 4598.76, "duration": 4.04 }, { "text": "longer string then let me go ahead and", "start": 4600.88, "duration": 4.04 }, { "text": "do this let me go ahead and grab that", "start": 4602.8, "duration": 5.52 }, { "text": "name in the variable split on not just", "start": 4604.92, "duration": 6.279 }, { "text": "the comma but the space after assuming", "start": 4608.32, "duration": 4.68 }, { "text": "the human typed in a space after their", "start": 4611.199, "duration": 3.721 }, { "text": "name and let me go ahead and store the", "start": 4613.0, "duration": 4.04 }, { "text": "result of that splitting of me comma", "start": 4614.92, "duration": 4.96 }, { "text": "David into two variables let's do last", "start": 4617.04, "duration": 5.36 }, { "text": "comma first again unpacking the sequence", "start": 4619.88, "duration": 5.64 }, { "text": "of values that comes back now let me go", "start": 4622.4, "duration": 4.88 }, { "text": "ahead and reformat the name so I'm going", "start": 4625.52, "duration": 3.76 }, { "text": "to forcibly change the user's name to be", "start": 4627.28, "duration": 4.399 }, { "text": "as I expect so name is actually going to", "start": 4629.28, "duration": 6.28 }, { "text": "be this format string first name then", "start": 4631.679, "duration": 6.121 }, { "text": "last name both in curly braces but", "start": 4635.56, "duration": 4.36 }, { "text": "formatt it together with a single space", "start": 4637.8, "duration": 4.72 }, { "text": "so that I'm overriding the user's input", "start": 4639.92, "duration": 4.48 }, { "text": "and updating my name variable", "start": 4642.52, "duration": 2.84 }, { "text": "accordingly", "start": 4644.4, "duration": 2.52 }, { "text": "for the moment to be clear this program", "start": 4645.36, "duration": 3.64 }, { "text": "is interactive like the users like me", "start": 4646.92, "duration": 4.48 }, { "text": "are typing their name into the program", "start": 4649.0, "duration": 5.0 }, { "text": "but imagine the data already is in a CSV", "start": 4651.4, "duration": 4.44 }, { "text": "file it came in from some process like a", "start": 4654.0, "duration": 3.92 }, { "text": "Google form or something else online you", "start": 4655.84, "duration": 4.16 }, { "text": "could imagine writing code similar to", "start": 4657.92, "duration": 4.239 }, { "text": "this but that maybe goes and reads that", "start": 4660.0, "duration": 4.6 }, { "text": "file into memory first maybe it's a CSV", "start": 4662.159, "duration": 5.0 }, { "text": "via CSV reader or a dict reader and then", "start": 4664.6, "duration": 4.36 }, { "text": "iterating over each of those names but", "start": 4667.159, "duration": 3.121 }, { "text": "we'll keep it simple and just do one", "start": 4668.96, "duration": 3.8 }, { "text": "name at a time but now what's kind of", "start": 4670.28, "duration": 4.08 }, { "text": "interesting here is if I go back to my", "start": 4672.76, "duration": 3.24 }, { "text": "terminal window window and clear it and", "start": 4674.36, "duration": 4.4 }, { "text": "run python of format. piy and hit enter", "start": 4676.0, "duration": 4.8 }, { "text": "I'm going to type in David space ma as", "start": 4678.76, "duration": 4.64 }, { "text": "before and I think we're still good but", "start": 4680.8, "duration": 4.6 }, { "text": "I'm also going to go ahead and do this", "start": 4683.4, "duration": 5.839 }, { "text": "python of format. py maen comma David", "start": 4685.4, "duration": 5.88 }, { "text": "with a space in between crossing my", "start": 4689.239, "duration": 5.521 }, { "text": "fingers and hit enter and voila that now", "start": 4691.28, "duration": 6.56 }, { "text": "has been fixed such a simple thing to be", "start": 4694.76, "duration": 5.959 }, { "text": "sure but it is so commonly necessary to", "start": 4697.84, "duration": 5.28 }, { "text": "clean up users input here we see at", "start": 4700.719, "duration": 5.601 }, { "text": "least one way to do so pretty easily now", "start": 4703.12, "duration": 5.44 }, { "text": "to be fair there's some problems here", "start": 4706.32, "duration": 3.96 }, { "text": "and in fact can someone imagine a", "start": 4708.56, "duration": 3.84 }, { "text": "scenario in which this code really", "start": 4710.28, "duration": 4.919 }, { "text": "doesn't fix the user's input what could", "start": 4712.4, "duration": 6.319 }, { "text": "still go wrong even with this fix in my", "start": 4715.199, "duration": 6.881 }, { "text": "code any thoughts if they type their in", "start": 4718.719, "duration": 6.281 }, { "text": "their name comma and then sign them oh", "start": 4722.08, "duration": 4.68 }, { "text": "and then something else yeah so let me", "start": 4725.0, "duration": 3.92 }, { "text": "let me try this for instance um let me", "start": 4726.76, "duration": 4.84 }, { "text": "go ahead and run a program and uh I am", "start": 4728.92, "duration": 4.64 }, { "text": "the only David men that I know but", "start": 4731.6, "duration": 5.68 }, { "text": "suppose I were uh uh let's say junior", "start": 4733.56, "duration": 5.76 }, { "text": "like this and it's common in English at", "start": 4737.28, "duration": 3.56 }, { "text": "least to sometimes put a comma there you", "start": 4739.32, "duration": 2.919 }, { "text": "don't necessarily need the comma but I'm", "start": 4740.84, "duration": 3.56 }, { "text": "one of those people who uses a comma", "start": 4742.239, "duration": 4.801 }, { "text": "that's now really really broken so I've", "start": 4744.4, "duration": 5.239 }, { "text": "broken some assumption there and so that", "start": 4747.04, "duration": 4.32 }, { "text": "could certainly go wrong here what else", "start": 4749.639, "duration": 2.961 }, { "text": "well let me go ahead and run this again", "start": 4751.36, "duration": 4.44 }, { "text": "and if I did ma comma David no space", "start": 4752.6, "duration": 4.48 }, { "text": "because I'm being a little sloppy I'm", "start": 4755.8, "duration": 3.08 }, { "text": "not paying attention which is going to", "start": 4757.08, "duration": 3.32 }, { "text": "happen when you have lots of users", "start": 4758.88, "duration": 3.799 }, { "text": "ultimately well this really broke now", "start": 4760.4, "duration": 4.839 }, { "text": "notice I have a value error and actual", "start": 4762.679, "duration": 6.121 }, { "text": "exception why well because split is", "start": 4765.239, "duration": 5.241 }, { "text": "supposed to be splitting the string into", "start": 4768.8, "duration": 4.399 }, { "text": "two strings by looking for the comma and", "start": 4770.48, "duration": 4.96 }, { "text": "a space but if there is no comma in", "start": 4773.199, "duration": 4.601 }, { "text": "space it can't split it into two things", "start": 4775.44, "duration": 4.68 }, { "text": "and the fact that I have two variables", "start": 4777.8, "duration": 5.0 }, { "text": "on the left but I'm only getting back", "start": 4780.12, "duration": 5.16 }, { "text": "one thing on the right means that I", "start": 4782.8, "duration": 4.52 }, { "text": "can't do this code quite as this so it's", "start": 4785.28, "duration": 4.04 }, { "text": "fragile to be sure but wouldn't it be", "start": 4787.32, "duration": 3.76 }, { "text": "nice if we could at least improve it for", "start": 4789.32, "duration": 3.16 }, { "text": "instance we now know some regular", "start": 4791.08, "duration": 3.68 }, { "text": "expression syntax what if I at least", "start": 4792.48, "duration": 5.04 }, { "text": "wanted to make this space optional well", "start": 4794.76, "duration": 4.36 }, { "text": "I could use my new found regular", "start": 4797.52, "duration": 3.159 }, { "text": "expression syntax and put a question", "start": 4799.12, "duration": 4.599 }, { "text": "mark question mark means zero or one of", "start": 4800.679, "duration": 5.121 }, { "text": "the things to the left what's the thing", "start": 4803.719, "duration": 4.041 }, { "text": "to the left it's literally a space I", "start": 4805.8, "duration": 3.64 }, { "text": "don't even need parentheses if there's", "start": 4807.76, "duration": 4.12 }, { "text": "just one thing there so that would be", "start": 4809.44, "duration": 4.68 }, { "text": "the start of a pattern that says I must", "start": 4811.88, "duration": 4.359 }, { "text": "have a comma and then I may or may not", "start": 4814.12, "duration": 4.32 }, { "text": "have a space zero or one spaces", "start": 4816.239, "duration": 5.041 }, { "text": "thereafter unfortunately the version of", "start": 4818.44, "duration": 6.64 }, { "text": "split that's built into the stir", "start": 4821.28, "duration": 6.28 }, { "text": "variable as in this case doesn't support", "start": 4825.08, "duration": 4.079 }, { "text": "regular Expressions if we want our", "start": 4827.56, "duration": 3.28 }, { "text": "regular Expressions we need to go use", "start": 4829.159, "duration": 3.801 }, { "text": "that Library here so let me go ahead and", "start": 4830.84, "duration": 4.799 }, { "text": "do this let me go in and leave this code", "start": 4832.96, "duration": 4.8 }, { "text": "AS is but go up to the top now and", "start": 4835.639, "duration": 4.721 }, { "text": "import re to import the library for", "start": 4837.76, "duration": 5.2 }, { "text": "regular expressions and now let me go", "start": 4840.36, "duration": 4.879 }, { "text": "ahead and start changing my Approach", "start": 4842.96, "duration": 4.6 }, { "text": "here I'm going to go ahead and do this", "start": 4845.239, "duration": 3.881 }, { "text": "I'm going to use the same function", "start": 4847.56, "duration": 4.079 }, { "text": "called re. search and I'm going to", "start": 4849.12, "duration": 5.72 }, { "text": "search for a pattern that I think will", "start": 4851.639, "duration": 5.721 }, { "text": "be last comma first so let me use my", "start": 4854.84, "duration": 4.56 }, { "text": "newfound regular expression syntax and", "start": 4857.36, "duration": 4.44 }, { "text": "represent a pattern for something like", "start": 4859.4, "duration": 6.239 }, { "text": "men comma space David how can I do this", "start": 4861.8, "duration": 6.68 }, { "text": "well inside of my quotes for re. search", "start": 4865.639, "duration": 6.321 }, { "text": "I'm going to have something so plus", "start": 4868.48, "duration": 6.679 }, { "text": "sorry I'm GNA have something so plus", "start": 4871.96, "duration": 5.12 }, { "text": "then I'm G to have a comma then I'm G to", "start": 4875.159, "duration": 3.641 }, { "text": "have a space then I'm going to have", "start": 4877.08, "duration": 4.079 }, { "text": "something plus now I'm going to", "start": 4878.8, "duration": 4.64 }, { "text": "preemptively refine this a little bit I", "start": 4881.159, "duration": 3.801 }, { "text": "want this whole pattern to start", "start": 4883.44, "duration": 2.96 }, { "text": "matching at the beginning of the user's", "start": 4884.96, "duration": 3.239 }, { "text": "input so I'm going to add the carrot", "start": 4886.4, "duration": 4.16 }, { "text": "right away and I want the end of the", "start": 4888.199, "duration": 4.48 }, { "text": "user's input to be matched as well so", "start": 4890.56, "duration": 4.0 }, { "text": "that I'm literally expecting any", "start": 4892.679, "duration": 4.361 }, { "text": "character one or more times then a comma", "start": 4894.56, "duration": 4.599 }, { "text": "then a space then any other character", "start": 4897.04, "duration": 5.24 }, { "text": "one or more times and then that is it", "start": 4899.159, "duration": 5.04 }, { "text": "and I'm going to pass in the name", "start": 4902.28, "duration": 5.16 }, { "text": "variable as before now when we've used", "start": 4904.199, "duration": 7.04 }, { "text": "re. search in the past we really used it", "start": 4907.44, "duration": 6.0 }, { "text": "just to answer a question does the", "start": 4911.239, "duration": 5.241 }, { "text": "user's input match the following pattern", "start": 4913.44, "duration": 6.68 }, { "text": "or not true or false effectively but re.", "start": 4916.48, "duration": 5.64 }, { "text": "search is actually more powerful than", "start": 4920.12, "duration": 4.16 }, { "text": "that you can actually get back more", "start": 4922.12, "duration": 4.88 }, { "text": "information and you can do this you can", "start": 4924.28, "duration": 4.56 }, { "text": "specify a variable and then an", "start": 4927.0, "duration": 4.159 }, { "text": "assignment operator and get back more", "start": 4928.84, "duration": 5.04 }, { "text": "precise answers to what has been found", "start": 4931.159, "duration": 5.08 }, { "text": "when searched for but what is it you", "start": 4933.88, "duration": 4.6 }, { "text": "want to get back well it turns out", "start": 4936.239, "duration": 4.0 }, { "text": "there's this other feature of regular", "start": 4938.48, "duration": 3.88 }, { "text": "Expressions which allow you to use", "start": 4940.239, "duration": 4.521 }, { "text": "parentheses not just to group things", "start": 4942.36, "duration": 5.4 }, { "text": "together but to capture them it turns", "start": 4944.76, "duration": 5.68 }, { "text": "out when you specify parentheses in a", "start": 4947.76, "duration": 4.959 }, { "text": "regular expression unbeknownst to us up", "start": 4950.44, "duration": 4.6 }, { "text": "until now everything in the parentheses", "start": 4952.719, "duration": 5.761 }, { "text": "will be returned to you as a return", "start": 4955.04, "duration": 6.599 }, { "text": "value from the re. search function it's", "start": 4958.48, "duration": 5.88 }, { "text": "going to allow you to extract specific", "start": 4961.639, "duration": 5.161 }, { "text": "amounts of information from the user's", "start": 4964.36, "duration": 4.44 }, { "text": "own input you can reverse this process", "start": 4966.8, "duration": 4.879 }, { "text": "too by using the non-capturing version", "start": 4968.8, "duration": 4.96 }, { "text": "as well you can use parentheses and then", "start": 4971.679, "duration": 4.121 }, { "text": "literally a Mark and a colon and then", "start": 4973.76, "duration": 3.6 }, { "text": "some other stuff and that will say don't", "start": 4975.8, "duration": 3.08 }, { "text": "bother capturing this I just want to", "start": 4977.36, "duration": 3.2 }, { "text": "group things but for now we're going to", "start": 4978.88, "duration": 4.2 }, { "text": "use just the parentheses themselves so", "start": 4980.56, "duration": 3.92 }, { "text": "how am I going to do this well if I want", "start": 4983.08, "duration": 4.559 }, { "text": "to get back the user's last name and", "start": 4984.48, "duration": 5.8 }, { "text": "first name I think what I want to", "start": 4987.639, "duration": 7.681 }, { "text": "capture is the plus here and the plus", "start": 4990.28, "duration": 7.879 }, { "text": "here so I've deliberately surrounded in", "start": 4995.32, "duration": 5.399 }, { "text": "parentheses the dot plus both to the", "start": 4998.159, "duration": 4.401 }, { "text": "left and the right of the comma not", "start": 5000.719, "duration": 3.44 }, { "text": "because I'm grouping them together per", "start": 5002.56, "duration": 3.48 }, { "text": "se I'm not adding a question mark I'm", "start": 5004.159, "duration": 4.48 }, { "text": "not adding up another Plus or a star I'm", "start": 5006.04, "duration": 5.639 }, { "text": "using parentheses now for capturing", "start": 5008.639, "duration": 5.641 }, { "text": "purposes why well I'm going to do this", "start": 5011.679, "duration": 4.721 }, { "text": "next I'm going to still ask a Boolean", "start": 5014.28, "duration": 5.0 }, { "text": "question like if there are matches then", "start": 5016.4, "duration": 6.12 }, { "text": "do this so if matches is not effectively", "start": 5019.28, "duration": 7.439 }, { "text": "false like none I do expect I've gotten", "start": 5022.52, "duration": 6.04 }, { "text": "back some matches and watch what I can", "start": 5026.719, "duration": 6.281 }, { "text": "do now I can do last comma first equals", "start": 5028.56, "duration": 6.56 }, { "text": "whatever matches in and get back all of", "start": 5033.0, "duration": 4.76 }, { "text": "the groups of matches then go ahead and", "start": 5035.12, "duration": 4.16 }, { "text": "update name just like before with a", "start": 5037.76, "duration": 4.919 }, { "text": "format string and do first and then last", "start": 5039.28, "duration": 5.48 }, { "text": "in curly braces as well and then at the", "start": 5042.679, "duration": 3.96 }, { "text": "very bottom just like before print out", "start": 5044.76, "duration": 5.919 }, { "text": "for instance hello comma name so the new", "start": 5046.639, "duration": 7.401 }, { "text": "code now is everything highlighted here", "start": 5050.679, "duration": 6.921 }, { "text": "I'm using re search to search for", "start": 5054.04, "duration": 5.8 }, { "text": "whether the user typed their name in", "start": 5057.6, "duration": 5.039 }, { "text": "last comma first format but I am more", "start": 5059.84, "duration": 6.04 }, { "text": "powerfully using re . search to capture", "start": 5062.639, "duration": 5.481 }, { "text": "some of the user's input what's going to", "start": 5065.88, "duration": 4.44 }, { "text": "get captured anything I surround it in", "start": 5068.12, "duration": 5.039 }, { "text": "parentheses will be returned to me as", "start": 5070.32, "duration": 5.44 }, { "text": "return values how do you get at those", "start": 5073.159, "duration": 4.801 }, { "text": "return values you ask the variable to", "start": 5075.76, "duration": 4.2 }, { "text": "which you assigned them for all of the", "start": 5077.96, "duration": 4.48 }, { "text": "groups all of the groups of parentheses", "start": 5079.96, "duration": 5.04 }, { "text": "that were captured so let me go ahead", "start": 5082.44, "duration": 4.6 }, { "text": "and do this let me go ahead now and run", "start": 5085.0, "duration": 5.239 }, { "text": "python of format. Pi enter and I'm going", "start": 5087.04, "duration": 6.56 }, { "text": "to type my name as usual in this case", "start": 5090.239, "duration": 6.281 }, { "text": "nothing happen happens with this if", "start": 5093.6, "duration": 5.079 }, { "text": "condition why because I did not type a", "start": 5096.52, "duration": 6.159 }, { "text": "comma and so this search does not find a", "start": 5098.679, "duration": 6.201 }, { "text": "comma so there are no matches so we", "start": 5102.679, "duration": 3.881 }, { "text": "immediately just print out hello name", "start": 5104.88, "duration": 4.319 }, { "text": "nothing interesting or new there but if", "start": 5106.56, "duration": 5.0 }, { "text": "I now go ahead and clear my screen and", "start": 5109.199, "duration": 5.04 }, { "text": "run python of format. and do maen commas", "start": 5111.56, "duration": 6.44 }, { "text": "space David enter we've reformatted my", "start": 5114.239, "duration": 6.161 }, { "text": "name well how did this work let me be a", "start": 5118.0, "duration": 4.8 }, { "text": "little more explicit now it turns out I", "start": 5120.4, "duration": 3.92 }, { "text": "don't have to just say matches. group", "start": 5122.8, "duration": 4.28 }, { "text": "groups I can get specific groups back", "start": 5124.32, "duration": 5.0 }, { "text": "that I want so let me change my code a", "start": 5127.08, "duration": 5.28 }, { "text": "little bit more let me go ahead now and", "start": 5129.32, "duration": 7.04 }, { "text": "just say this let's update name uh to", "start": 5132.36, "duration": 6.279 }, { "text": "well actually let's do this let's say", "start": 5136.36, "duration": 5.44 }, { "text": "that the last name is going to be in the", "start": 5138.639, "duration": 6.0 }, { "text": "matches but specifically group one the", "start": 5141.8, "duration": 4.839 }, { "text": "first name is going to be in the matches", "start": 5144.639, "duration": 3.881 }, { "text": "but specifically group two why one and", "start": 5146.639, "duration": 3.921 }, { "text": "two because this is the first set of", "start": 5148.52, "duration": 4.199 }, { "text": "parentheses to the left of the comma", "start": 5150.56, "duration": 3.92 }, { "text": "this is the second set of parentheses to", "start": 5152.719, "duration": 3.761 }, { "text": "the right of the comma and based on the", "start": 5154.48, "duration": 4.159 }, { "text": "input this would be the user's last name", "start": 5156.48, "duration": 4.32 }, { "text": "in this scenario me this would be the", "start": 5158.639, "duration": 5.161 }, { "text": "user's first name David in this scenario", "start": 5160.8, "duration": 5.72 }, { "text": "that's why I'm using group one for the", "start": 5163.8, "duration": 5.319 }, { "text": "last name and group two for the first", "start": 5166.52, "duration": 4.32 }, { "text": "name and now I'm going to go ahead and", "start": 5169.119, "duration": 6.281 }, { "text": "say name equals uh F string again uh", "start": 5170.84, "duration": 9.56 }, { "text": "first and then last done and let me", "start": 5175.4, "duration": 7.16 }, { "text": "refine this one last step before we take", "start": 5180.4, "duration": 3.92 }, { "text": "questions I don't really need these", "start": 5182.56, "duration": 3.76 }, { "text": "variables if I'm immediately using them", "start": 5184.32, "duration": 3.319 }, { "text": "let's just go ahead and tighten this up", "start": 5186.32, "duration": 2.76 }, { "text": "further as we've done in the past for", "start": 5187.639, "duration": 4.04 }, { "text": "design sake if I want to make the name", "start": 5189.08, "duration": 4.559 }, { "text": "the concatenation of the person's first", "start": 5191.679, "duration": 3.721 }, { "text": "name and last name let's just do this", "start": 5193.639, "duration": 6.961 }, { "text": "matches. group two first plus a space", "start": 5195.4, "duration": 8.799 }, { "text": "plus matches. group one so it's just up", "start": 5200.6, "duration": 5.76 }, { "text": "to me to know from left to right this is", "start": 5204.199, "duration": 4.601 }, { "text": "group one this is group two so group one", "start": 5206.36, "duration": 5.12 }, { "text": "is last group two is first so if I want", "start": 5208.8, "duration": 5.08 }, { "text": "to flip them around and update the value", "start": 5211.48, "duration": 4.92 }, { "text": "of name name I can explicitly get group", "start": 5213.88, "duration": 5.48 }, { "text": "two first concatenate using plus a", "start": 5216.4, "duration": 5.56 }, { "text": "single space and then concatenate on", "start": 5219.36, "duration": 6.04 }, { "text": "group one all right that was a lot let", "start": 5221.96, "duration": 5.6 }, { "text": "me pause to see if there are questions", "start": 5225.4, "duration": 3.6 }, { "text": "the key difference here is we're still", "start": 5227.56, "duration": 4.4 }, { "text": "using re. search the exact same way but", "start": 5229.0, "duration": 5.52 }, { "text": "now I'm using its return value not just", "start": 5231.96, "duration": 4.8 }, { "text": "to answer a question true or false but", "start": 5234.52, "duration": 4.719 }, { "text": "to actually get back specific matches", "start": 5236.76, "duration": 5.6 }, { "text": "anything I captured so to speak with", "start": 5239.239, "duration": 5.521 }, { "text": "parentheses why is it here we're using", "start": 5242.36, "duration": 4.879 }, { "text": "one and two instead of zero and one", "start": 5244.76, "duration": 4.439 }, { "text": "really good question caping the first a", "start": 5247.239, "duration": 3.801 }, { "text": "good observation in almost every other", "start": 5249.199, "duration": 3.881 }, { "text": "context we've started counting at zero", "start": 5251.04, "duration": 4.48 }, { "text": "and one instead of one and two it turns", "start": 5253.08, "duration": 4.52 }, { "text": "out there's something else in location", "start": 5255.52, "duration": 4.36 }, { "text": "zero when it comes back from re. search", "start": 5257.6, "duration": 4.16 }, { "text": "related to the string itself so", "start": 5259.88, "duration": 3.799 }, { "text": "according to the documentation of this", "start": 5261.76, "duration": 4.879 }, { "text": "function only one is the first set of", "start": 5263.679, "duration": 5.401 }, { "text": "parentheses and two is the second set", "start": 5266.639, "duration": 4.721 }, { "text": "and onward from there just a different", "start": 5269.08, "duration": 4.84 }, { "text": "convention here other questions uh what", "start": 5271.36, "duration": 6.56 }, { "text": "if we write nothing like whes space", "start": 5273.92, "duration": 7.68 }, { "text": "comma whes space uh how how we check um", "start": 5277.92, "duration": 6.6 }, { "text": "true of condition before I answer", "start": 5281.6, "duration": 4.28 }, { "text": "directly let me just run this and make", "start": 5284.52, "duration": 2.88 }, { "text": "sure I've not broken anything further", "start": 5285.88, "duration": 3.88 }, { "text": "let me run python of format. let me type", "start": 5287.4, "duration": 4.839 }, { "text": "in David space ma the right way let me", "start": 5289.76, "duration": 4.56 }, { "text": "run it once more let me type it Ma comma", "start": 5292.239, "duration": 4.44 }, { "text": "David the wrong way that we're fixing", "start": 5294.32, "duration": 4.44 }, { "text": "and we're still good but I think it will", "start": 5296.679, "duration": 3.721 }, { "text": "still break let me run it a third time", "start": 5298.76, "duration": 5.16 }, { "text": "with ma comma David with no space and", "start": 5300.4, "duration": 6.759 }, { "text": "now now it's still broken why because", "start": 5303.92, "duration": 7.279 }, { "text": "I'm still looking for comma space now", "start": 5307.159, "duration": 5.761 }, { "text": "how can I fix that one way I could do", "start": 5311.199, "duration": 3.44 }, { "text": "that is to add a question mark here", "start": 5312.92, "duration": 3.84 }, { "text": "which again is zero or more of the thing", "start": 5314.639, "duration": 4.6 }, { "text": "before so if I have a space and then a", "start": 5316.76, "duration": 4.32 }, { "text": "question mark literally no need for any", "start": 5319.239, "duration": 4.641 }, { "text": "parentheses then I can literally", "start": 5321.08, "duration": 6.599 }, { "text": "tolerate both ma comma space David or ma", "start": 5323.88, "duration": 6.359 }, { "text": "comma David so let's try again before", "start": 5327.679, "duration": 4.52 }, { "text": "this did not work let's do ma comma", "start": 5330.239, "duration": 5.241 }, { "text": "David with no space now it does actually", "start": 5332.199, "duration": 5.081 }, { "text": "work so we can tolerate different", "start": 5335.48, "duration": 4.12 }, { "text": "amounts of white space if I am a little", "start": 5337.28, "duration": 5.04 }, { "text": "more precise with my formula let me go", "start": 5339.6, "duration": 4.4 }, { "text": "ahead and try once more let me very", "start": 5342.32, "duration": 3.919 }, { "text": "weirdly but possibly hit the space bar a", "start": 5344.0, "duration": 4.08 }, { "text": "few too many times so now they're really", "start": 5346.239, "duration": 5.0 }, { "text": "separated this again is uh not going to", "start": 5348.08, "duration": 5.079 }, { "text": "work quite right because it's going to", "start": 5351.239, "duration": 4.601 }, { "text": "consume all of that white space so now I", "start": 5353.159, "duration": 5.161 }, { "text": "might want to strip left and right any", "start": 5355.84, "duration": 4.56 }, { "text": "of the leading white space on the result", "start": 5358.32, "duration": 4.72 }, { "text": "or what I could do here is say this", "start": 5360.4, "duration": 6.48 }, { "text": "instead of zero or one I could use a", "start": 5363.04, "duration": 7.4 }, { "text": "star here so space star and now if I run", "start": 5366.88, "duration": 5.839 }, { "text": "this once more with ma comma space space", "start": 5370.44, "duration": 4.6 }, { "text": "space David enter now we've cleaned up", "start": 5372.719, "duration": 4.321 }, { "text": "things further so you can imagine", "start": 5375.04, "duration": 4.199 }, { "text": "depending on how messy the data is that", "start": 5377.04, "duration": 3.639 }, { "text": "you're cleaning up your regular", "start": 5379.239, "duration": 3.0 }, { "text": "Expressions might need to get more and", "start": 5380.679, "duration": 3.56 }, { "text": "more sophisticated it really depends on", "start": 5382.239, "duration": 4.081 }, { "text": "just how many problems we want to solve", "start": 5384.239, "duration": 4.92 }, { "text": "at once well allow me to propose that we", "start": 5386.32, "duration": 5.24 }, { "text": "Forge ahead further just to clean this", "start": 5389.159, "duration": 4.401 }, { "text": "up even more so using a feature that's", "start": 5391.56, "duration": 5.079 }, { "text": "actually relatively new to python itself", "start": 5393.56, "duration": 5.119 }, { "text": "it is very common when using regular", "start": 5396.639, "duration": 3.961 }, { "text": "Expressions to do exactly what I've done", "start": 5398.679, "duration": 4.801 }, { "text": "here to call a function like re. search", "start": 5400.6, "duration": 5.8 }, { "text": "with capturing parentheses inside such", "start": 5403.48, "duration": 4.56 }, { "text": "that you get back a return value that", "start": 5406.4, "duration": 3.12 }, { "text": "I'm calling matches you could call it", "start": 5408.04, "duration": 2.96 }, { "text": "something else but I'm calling it by", "start": 5409.52, "duration": 3.639 }, { "text": "default matches and then notice on the", "start": 5411.0, "duration": 4.96 }, { "text": "next line I'm saying if matches wouldn't", "start": 5413.159, "duration": 4.08 }, { "text": "it be nice if I could just tighten", "start": 5415.96, "duration": 3.56 }, { "text": "things up further and do these all on", "start": 5417.239, "duration": 6.081 }, { "text": "the same line well you can sort of let", "start": 5419.52, "duration": 6.0 }, { "text": "me go ahead do this let me get rid of", "start": 5423.32, "duration": 4.319 }, { "text": "this if and let me just try to say", "start": 5425.52, "duration": 5.24 }, { "text": "something like this if matches equals re", "start": 5427.639, "duration": 7.321 }, { "text": "search and then colon so combining my if", "start": 5430.76, "duration": 7.16 }, { "text": "condition into just one line instead of", "start": 5434.96, "duration": 6.84 }, { "text": "those two um in C or C++ or Java you", "start": 5437.92, "duration": 5.48 }, { "text": "would actually do something like this", "start": 5441.8, "duration": 2.919 }, { "text": "surrounding the whole thing with", "start": 5443.4, "duration": 2.96 }, { "text": "parentheses sometimes double sets to", "start": 5444.719, "duration": 3.721 }, { "text": "suppress any warnings if you want to do", "start": 5446.36, "duration": 4.879 }, { "text": "two things at once if you want to not", "start": 5448.44, "duration": 6.56 }, { "text": "only assign the return value of re.", "start": 5451.239, "duration": 6.44 }, { "text": "search to a variable called matches but", "start": 5455.0, "duration": 4.92 }, { "text": "you want to subsequently ask a Boolean", "start": 5457.679, "duration": 5.241 }, { "text": "question is this effectively true or", "start": 5459.92, "duration": 4.68 }, { "text": "false that's what I was doing a moment", "start": 5462.92, "duration": 4.04 }, { "text": "ago let me undo this a moment ago I was", "start": 5464.6, "duration": 3.88 }, { "text": "getting back the return value and", "start": 5466.96, "duration": 3.96 }, { "text": "assigning it to matches and then I was", "start": 5468.48, "duration": 4.679 }, { "text": "asking the question well it turns out", "start": 5470.92, "duration": 4.6 }, { "text": "this need to have two lines of code", "start": 5473.159, "duration": 4.52 }, { "text": "presumably rubbed people wrong for too", "start": 5475.52, "duration": 4.119 }, { "text": "long in Python and so you can now", "start": 5477.679, "duration": 4.0 }, { "text": "combine these two kinds of lines into", "start": 5479.639, "duration": 4.921 }, { "text": "one but you need a new operator", "start": 5481.679, "duration": 5.641 }, { "text": "you cannot just say if matches equals re", "start": 5484.56, "duration": 5.36 }, { "text": "search and then analin at the end you", "start": 5487.32, "duration": 6.08 }, { "text": "instead need to do this you need to do", "start": 5489.92, "duration": 7.36 }, { "text": "colon equals if and only if you want to", "start": 5493.4, "duration": 6.319 }, { "text": "assign something from right to left and", "start": 5497.28, "duration": 5.16 }, { "text": "you want to ask an if or an L if", "start": 5499.719, "duration": 5.48 }, { "text": "question on the same line This is", "start": 5502.44, "duration": 4.48 }, { "text": "affectionately known as you can see here", "start": 5505.199, "duration": 4.681 }, { "text": "as the walrus operator and it's new to", "start": 5506.92, "duration": 5.44 }, { "text": "python in recent years and it both", "start": 5509.88, "duration": 5.319 }, { "text": "allows you to assign value as I'm doing", "start": 5512.36, "duration": 6.4 }, { "text": "from right to left and ask a Boolean", "start": 5515.199, "duration": 5.321 }, { "text": "question about it like I'm doing with", "start": 5518.76, "duration": 4.6 }, { "text": "the if or equivalently L if does anyone", "start": 5520.52, "duration": 5.119 }, { "text": "know why this is called The Walrus", "start": 5523.36, "duration": 5.6 }, { "text": "operator if you kind of look at it like", "start": 5525.639, "duration": 5.441 }, { "text": "this perhaps if you're familiar with", "start": 5528.96, "duration": 4.6 }, { "text": "walruses it kind of sort of looks like a", "start": 5531.08, "duration": 4.2 }, { "text": "walrus so a minor detail but a", "start": 5533.56, "duration": 3.559 }, { "text": "relatively new feature of python that", "start": 5535.28, "duration": 3.68 }, { "text": "honestly you'll probably continue to see", "start": 5537.119, "duration": 3.481 }, { "text": "online and in source code and in", "start": 5538.96, "duration": 3.96 }, { "text": "textbooks and so forth increasingly so", "start": 5540.6, "duration": 4.2 }, { "text": "now that it does exist it does not", "start": 5542.92, "duration": 3.68 }, { "text": "change the logic at all if I run Python", "start": 5544.8, "duration": 4.439 }, { "text": "A format. piy and type ma commas space", "start": 5546.6, "duration": 4.599 }, { "text": "David it still fixes things but it's", "start": 5549.239, "duration": 4.761 }, { "text": "tightened up my code just a bit more all", "start": 5551.199, "duration": 4.601 }, { "text": "right let's go ahead and look at one", "start": 5554.0, "duration": 4.199 }, { "text": "final problem to solve that of", "start": 5555.8, "duration": 4.919 }, { "text": "extracting information now as well so at", "start": 5558.199, "duration": 4.52 }, { "text": "this point we've now validated the", "start": 5560.719, "duration": 3.801 }, { "text": "user's input by checking whether or not", "start": 5562.719, "duration": 4.161 }, { "text": "it meets a certain pattern we've cleaned", "start": 5564.52, "duration": 5.04 }, { "text": "up the users input by checking against a", "start": 5566.88, "duration": 4.44 }, { "text": "pattern whether it matches or not and if", "start": 5569.56, "duration": 3.76 }, { "text": "it does match we kind of reorganize some", "start": 5571.32, "duration": 3.64 }, { "text": "of the users information so we can clean", "start": 5573.32, "duration": 3.52 }, { "text": "up their input and standardize the", "start": 5574.96, "duration": 3.36 }, { "text": "format in which we're storing or", "start": 5576.84, "duration": 3.399 }, { "text": "printing it in this case let's do one", "start": 5578.32, "duration": 3.48 }, { "text": "final example where we're very", "start": 5580.239, "duration": 4.161 }, { "text": "specifically extracting information in", "start": 5581.8, "duration": 5.2 }, { "text": "order to answer some question so let me", "start": 5584.4, "duration": 4.56 }, { "text": "propose this let me go ahead and close", "start": 5587.0, "duration": 4.199 }, { "text": "format. and create a new file called", "start": 5588.96, "duration": 4.96 }, { "text": "twitter. py the goal of which is to", "start": 5591.199, "duration": 5.361 }, { "text": "prompt users for the URL of their", "start": 5593.92, "duration": 6.0 }, { "text": "Twitter profile and extract from it", "start": 5596.56, "duration": 6.44 }, { "text": "infer from that URL what is the user's", "start": 5599.92, "duration": 4.719 }, { "text": "username now why might you want to do", "start": 5603.0, "duration": 3.28 }, { "text": "this well one you might want users to be", "start": 5604.639, "duration": 3.48 }, { "text": "able to just very easily copy and paste", "start": 5606.28, "duration": 4.04 }, { "text": "the URL from their own Twitter profile", "start": 5608.119, "duration": 5.0 }, { "text": "into your form into your app so that you", "start": 5610.32, "duration": 6.0 }, { "text": "can figure out what their uh username is", "start": 5613.119, "duration": 5.6 }, { "text": "or you might have a form that asks the", "start": 5616.32, "duration": 4.2 }, { "text": "user for their Twitter username and", "start": 5618.719, "duration": 3.48 }, { "text": "because people aren't necessarily paying", "start": 5620.52, "duration": 4.119 }, { "text": "very close attention some people type", "start": 5622.199, "duration": 4.561 }, { "text": "their username some people type their", "start": 5624.639, "duration": 4.761 }, { "text": "whole URL or something else altogether", "start": 5626.76, "duration": 4.0 }, { "text": "it would be nice now that you're a", "start": 5629.4, "duration": 3.2 }, { "text": "programmer to just be more tolerant of", "start": 5630.76, "duration": 3.64 }, { "text": "different types of input and just take", "start": 5632.6, "duration": 3.88 }, { "text": "on the burden of canonicalizing", "start": 5634.4, "duration": 4.36 }, { "text": "standardizing the data but being", "start": 5636.48, "duration": 4.28 }, { "text": "flexible with the users it's arguably a", "start": 5638.76, "duration": 3.76 }, { "text": "better user experience if you just let", "start": 5640.76, "duration": 4.24 }, { "text": "me copy paste or type in what I want you", "start": 5642.52, "duration": 5.04 }, { "text": "clean it up you're the programmer not me", "start": 5645.0, "duration": 4.92 }, { "text": "lenss for a better experience perhaps", "start": 5647.56, "duration": 4.04 }, { "text": "well let me go ahead and do this with", "start": 5649.92, "duration": 3.799 }, { "text": "twitter. let me first go ahead and", "start": 5651.6, "duration": 5.079 }, { "text": "prompt the user here for a value for a", "start": 5653.719, "duration": 5.241 }, { "text": "variable that I'll call URL and just ask", "start": 5656.679, "duration": 4.44 }, { "text": "them to input the URL of their Twitter", "start": 5658.96, "duration": 3.88 }, { "text": "profile I'm going to go ahead and strip", "start": 5661.119, "duration": 3.56 }, { "text": "off any leading or trailing whites space", "start": 5662.84, "duration": 3.44 }, { "text": "just in case users accidentally hit the", "start": 5664.679, "duration": 3.04 }, { "text": "space bar that's like literally the", "start": 5666.28, "duration": 4.08 }, { "text": "least I can do quite easily but now", "start": 5667.719, "duration": 5.161 }, { "text": "let's go ahead and do this suppose that", "start": 5670.36, "duration": 6.839 }, { "text": "the users's address is the following let", "start": 5672.88, "duration": 6.08 }, { "text": "me print out what they type in and let", "start": 5677.199, "duration": 3.361 }, { "text": "me clear my screen and run python of", "start": 5678.96, "duration": 3.48 }, { "text": "twitter. I'm going to go ahead and type", "start": 5680.56, "duration": 4.04 }, { "text": "in for instance", "start": 5682.44, "duration": 3.799 }, { "text": "https", "start": 5684.6, "duration": 4.119 }, { "text": "twitter.com davidj ma which happens to", "start": 5686.239, "duration": 4.92 }, { "text": "be my own Twitter username for now we're", "start": 5688.719, "duration": 3.761 }, { "text": "just going to print it back onto the", "start": 5691.159, "duration": 2.881 }, { "text": "screen just to make sure I've not messed", "start": 5692.48, "duration": 3.84 }, { "text": "up yet okay so I've printed back out the", "start": 5694.04, "duration": 4.079 }, { "text": "exact same URL but the goal at hand is", "start": 5696.32, "duration": 5.52 }, { "text": "to extract the username only now let me", "start": 5698.119, "duration": 6.12 }, { "text": "just ask perhaps a straightforward", "start": 5701.84, "duration": 5.359 }, { "text": "question logically what do I need to do", "start": 5704.239, "duration": 6.92 }, { "text": "to get at the user's username well uh we", "start": 5707.199, "duration": 6.761 }, { "text": "just ignore what's before the username", "start": 5711.159, "duration": 5.361 }, { "text": "and then just extract the username", "start": 5713.96, "duration": 4.08 }, { "text": "perfect yeah I mean it is as simple as", "start": 5716.52, "duration": 3.24 }, { "text": "that if you know the usernames at the", "start": 5718.04, "duration": 3.92 }, { "text": "end well let's just somehow ignore", "start": 5719.76, "duration": 3.68 }, { "text": "everything to the beginning well what's", "start": 5721.96, "duration": 3.4 }, { "text": "it beginning well it's a URL so we're", "start": 5723.44, "duration": 3.56 }, { "text": "probably going to need to ignore an", "start": 5725.36, "duration": 6.52 }, { "text": "https a colon a twitter.com and a slash", "start": 5727.0, "duration": 6.52 }, { "text": "so we just want to throw all of that", "start": 5731.88, "duration": 4.52 }, { "text": "away why because if it's URL We Know by", "start": 5733.52, "duration": 4.56 }, { "text": "how Twitter works that the username", "start": 5736.4, "duration": 4.16 }, { "text": "comes at the end so let's use that very", "start": 5738.08, "duration": 5.039 }, { "text": "simple idea to get at the information we", "start": 5740.56, "duration": 3.8 }, { "text": "want well I'm going to try this a few", "start": 5743.119, "duration": 2.841 }, { "text": "different ways let me go back into my", "start": 5744.36, "duration": 2.64 }, { "text": "program here and instead of just", "start": 5745.96, "duration": 2.84 }, { "text": "printing it out which was just to see", "start": 5747.0, "duration": 4.0 }, { "text": "what's going on let me do this let me", "start": 5748.8, "duration": 4.48 }, { "text": "create a new variable called username", "start": 5751.0, "duration": 6.36 }, { "text": "and let me call url. replace it turns", "start": 5753.28, "duration": 7.32 }, { "text": "out that if URL is a string or a stir in", "start": 5757.36, "duration": 5.44 }, { "text": "Python it again comes with multiple", "start": 5760.6, "duration": 5.4 }, { "text": "methods like strip uh and split and", "start": 5762.8, "duration": 5.319 }, { "text": "others as well one of which is called", "start": 5766.0, "duration": 4.36 }, { "text": "replace and replace will do just that", "start": 5768.119, "duration": 4.201 }, { "text": "you pass it two arguments the first of", "start": 5770.36, "duration": 4.24 }, { "text": "which is what do you want to replace the", "start": 5772.32, "duration": 4.12 }, { "text": "second argument is what do you want to", "start": 5774.6, "duration": 4.039 }, { "text": "replace it with so if I want to get rid", "start": 5776.44, "duration": 3.96 }, { "text": "of as I've been proposed really just", "start": 5778.639, "duration": 3.321 }, { "text": "everything before the username that is", "start": 5780.4, "duration": 4.68 }, { "text": "the Twitter URL or the beginning thereof", "start": 5781.96, "duration": 6.56 }, { "text": "let's just say this go ahead and replace", "start": 5785.08, "duration": 5.52 }, { "text": "https", "start": 5788.52, "duration": 4.639 }, { "text": "twitter.com close quote that's what I", "start": 5790.6, "duration": 4.8 }, { "text": "want to replace and comma second", "start": 5793.159, "duration": 3.56 }, { "text": "argument what do you want to replace it", "start": 5795.4, "duration": 3.319 }, { "text": "with nothing so I'm literally going to", "start": 5796.719, "duration": 4.44 }, { "text": "pass in quote unquote to effectively do", "start": 5798.719, "duration": 4.241 }, { "text": "a find and replace that's what the", "start": 5801.159, "duration": 3.321 }, { "text": "replace method does just like you can do", "start": 5802.96, "duration": 3.279 }, { "text": "it in Microsoft Word or Google Docs this", "start": 5804.48, "duration": 3.719 }, { "text": "is the programmer's way of doing find", "start": 5806.239, "duration": 4.96 }, { "text": "and replace now let me go ahead and", "start": 5808.199, "duration": 5.0 }, { "text": "print out just the username so I'll use", "start": 5811.199, "duration": 4.601 }, { "text": "an F string like this I'll say username", "start": 5813.199, "duration": 4.881 }, { "text": "colon and then in curly braces username", "start": 5815.8, "duration": 4.359 }, { "text": "just to format it nicely all right let", "start": 5818.08, "duration": 3.559 }, { "text": "me go ahead and clear my screen and run", "start": 5820.159, "duration": 4.401 }, { "text": "python of twitter. py enter URL here we", "start": 5821.639, "duration": 3.881 }, { "text": "go", "start": 5824.56, "duration": 3.96 }, { "text": "https", "start": 5825.52, "duration": 3.0 }, { "text": "twitter.com SL davidj maen enter okay", "start": 5828.56, "duration": 7.079 }, { "text": "now we've made some progress done for", "start": 5833.4, "duration": 5.56 }, { "text": "the day right well what is suboptimal", "start": 5835.639, "duration": 6.04 }, { "text": "about this can anyone critique or find", "start": 5838.96, "duration": 6.8 }, { "text": "fault with my program it is working now", "start": 5841.679, "duration": 6.921 }, { "text": "but it's a little fragile I bet we could", "start": 5845.76, "duration": 4.76 }, { "text": "contrive some scenarios where I think it", "start": 5848.6, "duration": 4.2 }, { "text": "works but it doesn't well I have a few", "start": 5850.52, "duration": 5.04 }, { "text": "ideas actually well first of all uh if", "start": 5852.8, "duration": 6.399 }, { "text": "we if we don't specify https it will", "start": 5855.56, "duration": 6.72 }, { "text": "broken secondly if we have slash at the", "start": 5859.199, "duration": 6.0 }, { "text": "end it also will be broken if we if we", "start": 5862.28, "duration": 5.399 }, { "text": "have like question mark something after", "start": 5865.199, "duration": 5.201 }, { "text": "question mark it also won't work so a", "start": 5867.679, "duration": 4.48 }, { "text": "lot of scenario actually oh my God I", "start": 5870.4, "duration": 3.839 }, { "text": "mean here we are I pretending to think I", "start": 5872.159, "duration": 3.721 }, { "text": "was done but my God like Alex gave us a", "start": 5874.239, "duration": 3.721 }, { "text": "whole laundry list of like problems and", "start": 5875.88, "duration": 3.799 }, { "text": "just to recap then what if it's not", "start": 5877.96, "duration": 4.92 }, { "text": "https it's HTTP slightly less secure but", "start": 5879.679, "duration": 5.0 }, { "text": "I should still be able to tolerate that", "start": 5882.88, "duration": 3.68 }, { "text": "programmatically uh what if the protocol", "start": 5884.679, "duration": 3.241 }, { "text": "is not there what if the user just type", "start": 5886.56, "duration": 3.52 }, { "text": "twitter.com davidj mailin it would be", "start": 5887.92, "duration": 4.12 }, { "text": "nice to tolerate that rather than show", "start": 5890.08, "duration": 3.519 }, { "text": "an error and make me type in the", "start": 5892.04, "duration": 3.36 }, { "text": "protocol why it's not good user", "start": 5893.599, "duration": 4.321 }, { "text": "experience what if it had a slash at the", "start": 5895.4, "duration": 4.64 }, { "text": "end of the username or a question mark", "start": 5897.92, "duration": 3.84 }, { "text": "If you think about URLs you've seen on", "start": 5900.04, "duration": 3.8 }, { "text": "the web there's very commonly more", "start": 5901.76, "duration": 3.479 }, { "text": "information especially if it's been", "start": 5903.84, "duration": 3.0 }, { "text": "shared on social media there might be", "start": 5905.239, "duration": 4.0 }, { "text": "HTTP parameters so to speak just stuff", "start": 5906.84, "duration": 3.759 }, { "text": "there that we don't want there could be", "start": 5909.239, "duration": 2.601 }, { "text": "a", "start": 5910.599, "duration": 3.281 }, { "text": "www.twitter.com which I'm also not", "start": 5911.84, "duration": 3.96 }, { "text": "expecting but does work if you go to", "start": 5913.88, "duration": 4.48 }, { "text": "that URL too so there's just so many", "start": 5915.8, "duration": 4.319 }, { "text": "things that can go wrong and even if I", "start": 5918.36, "duration": 3.96 }, { "text": "come back to my contrived example as", "start": 5920.119, "duration": 4.161 }, { "text": "earlier what if I run this program and", "start": 5922.32, "duration": 5.76 }, { "text": "say this uh my username is", "start": 5924.28, "duration": 5.359 }, { "text": "https", "start": 5928.08, "duration": 6.039 }, { "text": "twitter.com davidj mailen enter well", "start": 5929.639, "duration": 7.48 }, { "text": "that too just just didn't really work it", "start": 5934.119, "duration": 5.12 }, { "text": "got rid of the U", "start": 5937.119, "duration": 4.0 }, { "text": "actually okay actually that kind of", "start": 5939.239, "duration": 4.761 }, { "text": "worked but the goal here is to actually", "start": 5941.119, "duration": 4.961 }, { "text": "get the user's username not an English", "start": 5944.0, "duration": 4.159 }, { "text": "sentence describing the user's username", "start": 5946.08, "duration": 4.119 }, { "text": "so I would argue that even though I just", "start": 5948.159, "duration": 3.721 }, { "text": "accidentally created perfectly correct", "start": 5950.199, "duration": 4.201 }, { "text": "English grammar I did not extract the", "start": 5951.88, "duration": 4.52 }, { "text": "Twitter username correctly I don't want", "start": 5954.4, "duration": 4.839 }, { "text": "words like my username is as part of my", "start": 5956.4, "duration": 5.08 }, { "text": "input so how can we go about improving", "start": 5959.239, "duration": 3.92 }, { "text": "this and maybe chipping away at some of", "start": 5961.48, "duration": 3.239 }, { "text": "those problems one by one well let me", "start": 5963.159, "duration": 3.681 }, { "text": "clear my screen here let me come back up", "start": 5964.719, "duration": 4.641 }, { "text": "to my code and let me not just replace", "start": 5966.84, "duration": 4.799 }, { "text": "it but let me do something else instead", "start": 5969.36, "duration": 3.839 }, { "text": "I'm going to go ahead and instead of", "start": 5971.639, "duration": 3.241 }, { "text": "using replace I'm going to use another", "start": 5973.199, "duration": 4.601 }, { "text": "function called remove prefix a prefix", "start": 5974.88, "duration": 5.44 }, { "text": "is a string or a subring that comes at", "start": 5977.8, "duration": 5.2 }, { "text": "the start of another so if I remove", "start": 5980.32, "duration": 4.279 }, { "text": "prefix I don't need a second argument", "start": 5983.0, "duration": 3.76 }, { "text": "for this function I just need one what", "start": 5984.599, "duration": 4.281 }, { "text": "prefix do you want to remove so this", "start": 5986.76, "duration": 4.879 }, { "text": "will at least now fix the problem I just", "start": 5988.88, "duration": 4.759 }, { "text": "described of typing in like a whole sent", "start": 5991.639, "duration": 3.96 }, { "text": "where the URL is there but it's not the", "start": 5993.639, "duration": 4.841 }, { "text": "beginning it's only at the end so here", "start": 5995.599, "duration": 4.801 }, { "text": "this still is not correct but we don't", "start": 5998.48, "duration": 3.759 }, { "text": "create this weird looking output that", "start": 6000.4, "duration": 4.839 }, { "text": "just removes the URL part of the input", "start": 6002.239, "duration": 5.761 }, { "text": "uh my username is", "start": 6005.239, "duration": 6.601 }, { "text": "htps twitter.com davidj maen a moment", "start": 6008.0, "duration": 7.4 }, { "text": "ago it did remove the URL and left only", "start": 6011.84, "duration": 6.08 }, { "text": "the David J ma this is not perfect still", "start": 6015.4, "duration": 4.96 }, { "text": "but at least now it does not weirdly", "start": 6017.92, "duration": 4.52 }, { "text": "remove the URL and then leave the", "start": 6020.36, "duration": 4.4 }, { "text": "English it's just leaving it alone so", "start": 6022.44, "duration": 3.84 }, { "text": "maybe I could handle this better but at", "start": 6024.76, "duration": 3.399 }, { "text": "least it's removing it from the part of", "start": 6026.28, "duration": 3.56 }, { "text": "the string I might", "start": 6028.159, "duration": 3.921 }, { "text": "anticipate well what else could we do", "start": 6029.84, "duration": 4.12 }, { "text": "here well it turns out that like regular", "start": 6032.08, "duration": 4.639 }, { "text": "Expressions just let us express patterns", "start": 6033.96, "duration": 4.8 }, { "text": "much more precisely we could spend all", "start": 6036.719, "duration": 3.52 }, { "text": "day using a whole bunch of different", "start": 6038.76, "duration": 3.52 }, { "text": "python functions like remove prefix or", "start": 6040.239, "duration": 4.561 }, { "text": "remove and strip and others and kind of", "start": 6042.28, "duration": 5.359 }, { "text": "make our way to the right solution but a", "start": 6044.8, "duration": 4.48 }, { "text": "regular expression just allows you to", "start": 6047.639, "duration": 3.681 }, { "text": "more succinctly if admittedly more", "start": 6049.28, "duration": 4.6 }, { "text": "cryptically Express these kinds of", "start": 6051.32, "duration": 4.56 }, { "text": "patterns and goals and we've seen from", "start": 6053.88, "duration": 4.0 }, { "text": "parentheses which can be used not just", "start": 6055.88, "duration": 4.92 }, { "text": "to group symbols together as sets but to", "start": 6057.88, "duration": 5.359 }, { "text": "capture information as well we have a", "start": 6060.8, "duration": 5.919 }, { "text": "very powerful tool now in our toolkit so", "start": 6063.239, "duration": 6.161 }, { "text": "let me do this let me go ahead and start", "start": 6066.719, "duration": 6.0 }, { "text": "fresh here and import the re Library as", "start": 6069.4, "duration": 5.08 }, { "text": "before at the very top of my program I'm", "start": 6072.719, "duration": 3.92 }, { "text": "still going to get the user's URL via", "start": 6074.48, "duration": 4.04 }, { "text": "the same line of code but I'm now going", "start": 6076.639, "duration": 4.761 }, { "text": "to use another function as well it turns", "start": 6078.52, "duration": 5.28 }, { "text": "out that there's not just re do search", "start": 6081.4, "duration": 4.88 }, { "text": "or rd. match or re. full match there's", "start": 6083.8, "duration": 5.879 }, { "text": "also re. sub in the regular expression", "start": 6086.28, "duration": 5.839 }, { "text": "Library where sub here means substitute", "start": 6089.679, "duration": 4.241 }, { "text": "and it takes more arguments but they're", "start": 6092.119, "duration": 3.52 }, { "text": "fairly straightforward the first", "start": 6093.92, "duration": 4.12 }, { "text": "argument to re.sub is the pattern the", "start": 6095.639, "duration": 4.04 }, { "text": "regular expression that you want to look", "start": 6098.04, "duration": 4.76 }, { "text": "for then you have a replacement string", "start": 6099.679, "duration": 5.241 }, { "text": "what do you want to replace that pattern", "start": 6102.8, "duration": 4.2 }, { "text": "with and where do you want to do all", "start": 6104.92, "duration": 4.279 }, { "text": "that will you pass in the string that", "start": 6107.0, "duration": 4.56 }, { "text": "you want to do the substitution on then", "start": 6109.199, "duration": 3.761 }, { "text": "there's some other arguments that I'll", "start": 6111.56, "duration": 3.039 }, { "text": "wave my hands up for now among them are", "start": 6112.96, "duration": 3.4 }, { "text": "those same flags and also a count like", "start": 6114.599, "duration": 3.52 }, { "text": "how many times do you want to do find", "start": 6116.36, "duration": 3.92 }, { "text": "and replace do you want it to do all or", "start": 6118.119, "duration": 4.0 }, { "text": "do you want to do it just one or so", "start": 6120.28, "duration": 3.439 }, { "text": "forth you can have further control there", "start": 6122.119, "duration": 3.401 }, { "text": "too just like you would in Google Docs", "start": 6123.719, "duration": 3.88 }, { "text": "or Microsoft Word well let me go back to", "start": 6125.52, "duration": 4.76 }, { "text": "my code here and let me do this I'm", "start": 6127.599, "duration": 5.0 }, { "text": "going to go ahead and call re not search", "start": 6130.28, "duration": 5.319 }, { "text": "but re.sub for substitute I'm going to", "start": 6132.599, "duration": 5.761 }, { "text": "pass in the following regular expression", "start": 6135.599, "duration": 4.281 }, { "text": "https", "start": 6138.36, "duration": 3.52 }, { "text": "col", "start": 6139.88, "duration": 4.52 }, { "text": "twitter.com uh slash and then I'm going", "start": 6141.88, "duration": 4.68 }, { "text": "to close my quote and now what do I want", "start": 6144.4, "duration": 4.799 }, { "text": "to replace that with well like before", "start": 6146.56, "duration": 4.88 }, { "text": "with the simple stir replace function I", "start": 6149.199, "duration": 3.641 }, { "text": "want to replace it with nothing just get", "start": 6151.44, "duration": 4.08 }, { "text": "rid of it all together but what uh", "start": 6152.84, "duration": 4.279 }, { "text": "string do I want to pass in to do this", "start": 6155.52, "duration": 5.4 }, { "text": "to the URL from the user and now let me", "start": 6157.119, "duration": 6.241 }, { "text": "go ahead and assign the return value of", "start": 6160.92, "duration": 5.279 }, { "text": "re sub to a variable called username so", "start": 6163.36, "duration": 5.239 }, { "text": "re sub's purpose in life is again to", "start": 6166.199, "duration": 5.0 }, { "text": "substitute some value for some regular", "start": 6168.599, "duration": 3.921 }, { "text": "expression some number of times it", "start": 6171.199, "duration": 3.801 }, { "text": "essentially is find and replace using", "start": 6172.52, "duration": 4.719 }, { "text": "regular expressions and it returns to", "start": 6175.0, "duration": 4.52 }, { "text": "you the resulting string once you've", "start": 6177.239, "duration": 4.681 }, { "text": "done all those substitutions so now the", "start": 6179.52, "duration": 3.84 }, { "text": "very last line of my code can be the", "start": 6181.92, "duration": 3.799 }, { "text": "same as before print and I'll use an F", "start": 6183.36, "duration": 4.92 }, { "text": "string username colon and then in curly", "start": 6185.719, "duration": 4.561 }, { "text": "braces username so I can print out", "start": 6188.28, "duration": 4.959 }, { "text": "literally just that all right let's try", "start": 6190.28, "duration": 4.359 }, { "text": "this and see what happens I'll clear my", "start": 6193.239, "duration": 4.201 }, { "text": "terminal window run python of twitter.", "start": 6194.639, "duration": 4.881 }, { "text": "and here we go https", "start": 6197.44, "duration": 3.64 }, { "text": "col", "start": 6199.52, "duration": 4.24 }, { "text": "twitter.com davidj Ma", "start": 6201.08, "duration": 6.159 }, { "text": "cross my fingers and hit enter okay now", "start": 6203.76, "duration": 5.64 }, { "text": "we're in business but it is still a", "start": 6207.239, "duration": 4.96 }, { "text": "little fragile and so let me ask the", "start": 6209.4, "duration": 5.759 }, { "text": "group what problem should I now further", "start": 6212.199, "duration": 4.92 }, { "text": "chip away at they've been said before", "start": 6215.159, "duration": 3.56 }, { "text": "but let's be clear what's one or more", "start": 6217.119, "duration": 4.241 }, { "text": "problems that still remain the protocols", "start": 6218.719, "duration": 6.801 }, { "text": "and the uh domain prefixes for good the", "start": 6221.36, "duration": 7.04 }, { "text": "protocol so HTTP versus https maybe the", "start": 6225.52, "duration": 6.56 }, { "text": "subdomain www should it be there or not", "start": 6228.4, "duration": 5.48 }, { "text": "and there's a few other mistakes here", "start": 6232.08, "duration": 3.639 }, { "text": "too let me actually stay with the group", "start": 6233.88, "duration": 3.68 }, { "text": "what are some other shortcomings of this", "start": 6235.719, "duration": 6.081 }, { "text": "current solution um if we use a phrase", "start": 6237.56, "duration": 6.8 }, { "text": "like you do before we are going to have", "start": 6241.8, "duration": 5.72 }, { "text": "the same problem because it's not taken", "start": 6244.36, "duration": 6.0 }, { "text": "account in the first part of the the", "start": 6247.52, "duration": 5.48 }, { "text": "text symbol good I might still allow for", "start": 6250.36, "duration": 4.96 }, { "text": "like some words uh some English to the", "start": 6253.0, "duration": 3.84 }, { "text": "left of the URL because I didn't use", "start": 6255.32, "duration": 3.56 }, { "text": "like my carrot symbol so I'll fix that", "start": 6256.84, "duration": 3.6 }, { "text": "and any final observations on", "start": 6258.88, "duration": 4.759 }, { "text": "shortcomings here uh well the could be a", "start": 6260.44, "duration": 5.84 }, { "text": "HTTP or there could be like less than", "start": 6263.639, "duration": 4.96 }, { "text": "two slashes okay so it could be HTTP and", "start": 6266.28, "duration": 3.439 }, { "text": "I think that was mentioned too in terms", "start": 6268.599, "duration": 2.841 }, { "text": "of protocol there could be fewer than", "start": 6269.719, "duration": 4.44 }, { "text": "two slashes that I'm not going to worry", "start": 6271.44, "duration": 4.88 }, { "text": "about if the user gives me one slash", "start": 6274.159, "duration": 4.48 }, { "text": "instead of two that's really user error", "start": 6276.32, "duration": 4.2 }, { "text": "and I could be tolerant of it but you", "start": 6278.639, "duration": 4.281 }, { "text": "know what at that point I'm okay yelling", "start": 6280.52, "duration": 3.92 }, { "text": "at them with an error message saying", "start": 6282.92, "duration": 3.08 }, { "text": "please fix your input otherwise we could", "start": 6284.44, "duration": 3.08 }, { "text": "be here all day long trying to handle", "start": 6286.0, "duration": 4.159 }, { "text": "all possible typos for now I think in", "start": 6287.52, "duration": 4.92 }, { "text": "the interest of usability or user", "start": 6290.159, "duration": 4.921 }, { "text": "experience ux let's at least be tolerant", "start": 6292.44, "duration": 5.0 }, { "text": "of all possible valid inputs or", "start": 6295.08, "duration": 4.519 }, { "text": "reasonable inputs if you will so let me", "start": 6297.44, "duration": 3.84 }, { "text": "go here and let me start chipping away", "start": 6299.599, "duration": 3.321 }, { "text": "at these here what are some problems we", "start": 6301.28, "duration": 5.359 }, { "text": "can solve well let me propose that we", "start": 6302.92, "duration": 5.88 }, { "text": "first address the issue of matching from", "start": 6306.639, "duration": 3.721 }, { "text": "the beginning of the string so let me", "start": 6308.8, "duration": 3.72 }, { "text": "add the carrot to the beginning and let", "start": 6310.36, "duration": 4.92 }, { "text": "me add not a dollar sign at the end", "start": 6312.52, "duration": 3.84 }, { "text": "though right because I don't want to", "start": 6315.28, "duration": 2.56 }, { "text": "match all the way to the end because I", "start": 6316.36, "duration": 3.799 }, { "text": "want to tolerate a username there so I", "start": 6317.84, "duration": 4.839 }, { "text": "think we just want the carrot symbol", "start": 6320.159, "duration": 4.921 }, { "text": "there there's a subtle bug that no one", "start": 6322.679, "duration": 4.48 }, { "text": "yet mentioned and let me just kind of", "start": 6325.08, "duration": 5.0 }, { "text": "highlight it and see if it jumps out at", "start": 6327.159, "duration": 4.921 }, { "text": "you now it's a little subtle here on my", "start": 6330.08, "duration": 6.119 }, { "text": "screen I've highlighted in blue a final", "start": 6332.08, "duration": 7.44 }, { "text": "bug here maybe some Smiles on the screen", "start": 6336.199, "duration": 6.801 }, { "text": "yeah can we take one hand here why am I", "start": 6339.52, "duration": 6.36 }, { "text": "highlighting the dot in twitter.com even", "start": 6343.0, "duration": 5.28 }, { "text": "though it definitely should be there so", "start": 6345.88, "duration": 5.4 }, { "text": "the dot without a backlash mean any c is", "start": 6348.28, "duration": 5.879 }, { "text": "up a new line yeah exactly it's not it's", "start": 6351.28, "duration": 5.0 }, { "text": "means any character so I could type in", "start": 6354.159, "duration": 5.52 }, { "text": "something like Twitter uh question markc", "start": 6356.28, "duration": 6.0 }, { "text": "or Twitter anything C and that would", "start": 6359.679, "duration": 5.0 }, { "text": "actually be tolerated it's not really", "start": 6362.28, "duration": 4.839 }, { "text": "that bad cuz why would the user do that", "start": 6364.679, "duration": 4.48 }, { "text": "but if I want to be correct and I want", "start": 6367.119, "duration": 4.681 }, { "text": "to be able to test my own code properly", "start": 6369.159, "duration": 4.201 }, { "text": "I should really get this detail right so", "start": 6371.8, "duration": 3.64 }, { "text": "that's an easy fix too but it's a common", "start": 6373.36, "duration": 3.96 }, { "text": "mistake anytime you're writing regular", "start": 6375.44, "duration": 3.719 }, { "text": "Expressions that happen to involve", "start": 6377.32, "duration": 5.0 }, { "text": "special symbols like dots in a URL or", "start": 6379.159, "duration": 5.48 }, { "text": "domain name a dollar sign in something", "start": 6382.32, "duration": 4.48 }, { "text": "involving currency remember you might", "start": 6384.639, "duration": 4.121 }, { "text": "indeed Need to Escape it with a", "start": 6386.8, "duration": 4.12 }, { "text": "backslash like this here all right let", "start": 6388.76, "duration": 4.399 }, { "text": "me ask the group about the protocol", "start": 6390.92, "duration": 5.08 }, { "text": "specifically https is a good thing in", "start": 6393.159, "duration": 4.881 }, { "text": "the world it means secure there is", "start": 6396.0, "duration": 4.199 }, { "text": "encryption being used so generally you", "start": 6398.04, "duration": 4.599 }, { "text": "like to see https but you still see", "start": 6400.199, "duration": 6.4 }, { "text": "people typing or copy pasting HTTP what", "start": 6402.639, "duration": 6.52 }, { "text": "would be the simplest fix here to", "start": 6406.599, "duration": 6.08 }, { "text": "tolerate as has been proposed both HTTP", "start": 6409.159, "duration": 6.601 }, { "text": "and and https I'm going to propose that", "start": 6412.679, "duration": 5.841 }, { "text": "I could do this I could do HTTP vertical", "start": 6415.76, "duration": 6.919 }, { "text": "bar or https which again Means A or B", "start": 6418.52, "duration": 6.04 }, { "text": "but I think I can be smarter than that I", "start": 6422.679, "duration": 4.201 }, { "text": "can keep my code a little more succinct", "start": 6424.56, "duration": 4.84 }, { "text": "any recommendations here for", "start": 6426.88, "duration": 5.56 }, { "text": "tolerating HTTP or", "start": 6429.4, "duration": 6.04 }, { "text": "https we could try to put an question", "start": 6432.44, "duration": 5.719 }, { "text": "mark behind the S perfect just use a", "start": 6435.44, "duration": 4.44 }, { "text": "question mark right like both of those", "start": 6438.159, "duration": 3.241 }, { "text": "would be viable Solutions if you want to", "start": 6439.88, "duration": 3.719 }, { "text": "be super explicit in your code fine use", "start": 6441.4, "duration": 5.6 }, { "text": "parenthesis and say HTTP or https so", "start": 6443.599, "duration": 5.241 }, { "text": "that you the reader your boss your", "start": 6447.0, "duration": 3.679 }, { "text": "teacher just know exactly what you're", "start": 6448.84, "duration": 4.24 }, { "text": "doing but you know if you keep taking", "start": 6450.679, "duration": 4.081 }, { "text": "the more of verbose approach all the", "start": 6453.08, "duration": 3.32 }, { "text": "time it might actually become less", "start": 6454.76, "duration": 3.52 }, { "text": "readable certainly once your regular", "start": 6456.4, "duration": 3.799 }, { "text": "Expressions get this big instead of this", "start": 6458.28, "duration": 4.16 }, { "text": "big so let's save space where we can and", "start": 6460.199, "duration": 3.761 }, { "text": "I would argue that this is pretty", "start": 6462.44, "duration": 3.32 }, { "text": "reasonable so long as you're in the", "start": 6463.96, "duration": 3.639 }, { "text": "habits of reading regular expressions", "start": 6465.76, "duration": 3.28 }, { "text": "and know that question mark does not", "start": 6467.599, "duration": 3.0 }, { "text": "mean a literal question mark but it", "start": 6469.04, "duration": 4.159 }, { "text": "means zero or one of the thing before I", "start": 6470.599, "duration": 4.761 }, { "text": "think we've effectively made the S", "start": 6473.199, "duration": 5.081 }, { "text": "optional here now what else can I do", "start": 6475.36, "duration": 6.08 }, { "text": "well suppose we want to tolerate the www", "start": 6478.28, "duration": 5.72 }, { "text": "dot which may or may not be there uh but", "start": 6481.44, "duration": 4.759 }, { "text": "it will work if you go to a browser I", "start": 6484.0, "duration": 4.52 }, { "text": "could do this", "start": 6486.199, "duration": 5.201 }, { "text": "www. uh wait I want a backslash there so", "start": 6488.52, "duration": 4.24 }, { "text": "I don't repeat the same mistake as", "start": 6491.4, "duration": 3.44 }, { "text": "before but this is no good either", "start": 6492.76, "duration": 5.359 }, { "text": "because I want to tolerate www being", "start": 6494.84, "duration": 5.48 }, { "text": "there or not being there and now I've", "start": 6498.119, "duration": 4.04 }, { "text": "just required that it be there but I", "start": 6500.32, "duration": 4.44 }, { "text": "think I can take same approach any", "start": 6502.159, "duration": 5.401 }, { "text": "recommendations how do I make the www do", "start": 6504.76, "duration": 5.879 }, { "text": "optional just to hammer this home we can", "start": 6507.56, "duration": 6.72 }, { "text": "like group uh make a square", "start": 6510.639, "duration": 6.56 }, { "text": "and question mark perfect so question", "start": 6514.28, "duration": 5.0 }, { "text": "mark is the short answer again but we", "start": 6517.199, "duration": 3.48 }, { "text": "have to be a little smarter this time as", "start": 6519.28, "duration": 3.839 }, { "text": "Maria's noted we need parentheses now", "start": 6520.679, "duration": 4.401 }, { "text": "because if I just put a question mark", "start": 6523.119, "duration": 4.681 }, { "text": "after the dot that just means the dot is", "start": 6525.08, "duration": 4.28 }, { "text": "optional and that's wrong because we", "start": 6527.8, "duration": 5.0 }, { "text": "don't want the user to type in wwwt w i", "start": 6529.36, "duration": 6.16 }, { "text": "TT e r we want the dot to be there or", "start": 6532.8, "duration": 5.2 }, { "text": "just not at all with no www so we need", "start": 6535.52, "duration": 4.76 }, { "text": "to group this whole thing together put a", "start": 6538.0, "duration": 4.56 }, { "text": "parenthesis there and then a parenthesis", "start": 6540.28, "duration": 5.839 }, { "text": "not after the third W after the dot so", "start": 6542.56, "duration": 6.2 }, { "text": "that that whole thing is either there or", "start": 6546.119, "duration": 5.161 }, { "text": "it's not there and what else could we", "start": 6548.76, "duration": 4.2 }, { "text": "still do here you know there's going to", "start": 6551.28, "duration": 3.24 }, { "text": "be one other thing we should tolerate", "start": 6552.96, "duration": 2.92 }, { "text": "and it's been said before and I'll pluck", "start": 6554.52, "duration": 3.76 }, { "text": "this one off what about the protocol", "start": 6555.88, "duration": 4.08 }, { "text": "like what if the user just doesn't type", "start": 6558.28, "duration": 4.879 }, { "text": "or doesn't copy paste the HTTP colon SL", "start": 6559.96, "duration": 6.679 }, { "text": "slash or an htps colon slash right", "start": 6563.159, "duration": 5.281 }, { "text": "honestly you and I are not in the habit", "start": 6566.639, "duration": 3.881 }, { "text": "generally of even typing the protocol", "start": 6568.44, "duration": 3.88 }, { "text": "anymore nowadays you just let the", "start": 6570.52, "duration": 3.56 }, { "text": "browser figure it out for you and", "start": 6572.32, "duration": 4.799 }, { "text": "automatically add it instead so this", "start": 6574.08, "duration": 4.2 }, { "text": "one's going to look like more of a", "start": 6577.119, "duration": 3.681 }, { "text": "mouthful but if I want this whole thing", "start": 6578.28, "duration": 5.439 }, { "text": "here in blue to be optional it's", "start": 6580.8, "duration": 4.76 }, { "text": "actually the same solution as Maria", "start": 6583.719, "duration": 3.681 }, { "text": "offered a moment ago I'm going to go", "start": 6585.56, "duration": 4.039 }, { "text": "ahead and put a parenthesis over here", "start": 6587.4, "duration": 4.64 }, { "text": "and a parenthesis after the two slashes", "start": 6589.599, "duration": 3.681 }, { "text": "and then", "start": 6592.04, "duration": 3.48 }, { "text": "a question mark so it's to make that", "start": 6593.28, "duration": 4.439 }, { "text": "whole thing optional as well and this is", "start": 6595.52, "duration": 4.719 }, { "text": "okay it's totally fine to make this", "start": 6597.719, "duration": 5.681 }, { "text": "whole thing optional or inside of it", "start": 6600.239, "duration": 5.761 }, { "text": "this little thing just the S optional as", "start": 6603.4, "duration": 4.56 }, { "text": "well so long as I'm applying the same", "start": 6606.0, "duration": 3.76 }, { "text": "principles again and again either on a", "start": 6607.96, "duration": 3.759 }, { "text": "small scale or a bigger scale it's", "start": 6609.76, "duration": 5.08 }, { "text": "totally fine to Nest one of these inside", "start": 6611.719, "duration": 4.161 }, { "text": "of the", "start": 6614.84, "duration": 4.879 }, { "text": "other questions now on any of these", "start": 6615.88, "duration": 6.12 }, { "text": "refinements to this parsing this", "start": 6619.719, "duration": 5.44 }, { "text": "analyzing of Twitter what if we put a", "start": 6622.0, "duration": 7.84 }, { "text": "vertical bar besides this www do what if", "start": 6625.159, "duration": 7.08 }, { "text": "we use a a vertical bar there so we", "start": 6629.84, "duration": 4.319 }, { "text": "could do something like that too we", "start": 6632.239, "duration": 4.841 }, { "text": "could do something like this uh instead", "start": 6634.159, "duration": 6.56 }, { "text": "of the question mark I could do www. or", "start": 6637.08, "duration": 5.76 }, { "text": "nothing and just leave that in the", "start": 6640.719, "duration": 4.641 }, { "text": "parenthesis that too would be fine I", "start": 6642.84, "duration": 3.92 }, { "text": "personally tend not to like that because", "start": 6645.36, "duration": 3.279 }, { "text": "it's a little less obvious to me wait a", "start": 6646.76, "duration": 3.359 }, { "text": "minute is that deliberate or did I", "start": 6648.639, "duration": 3.241 }, { "text": "forget to finish my thought by putting", "start": 6650.119, "duration": 3.681 }, { "text": "something after the vertical bar but", "start": 6651.88, "duration": 4.48 }, { "text": "that too would be allowed there as well", "start": 6653.8, "duration": 4.68 }, { "text": "if that's what you mean other questions", "start": 6656.36, "duration": 3.719 }, { "text": "on where we left things here where we", "start": 6658.48, "duration": 5.4 }, { "text": "made the protocol optional too what", "start": 6660.079, "duration": 7.481 }, { "text": "coulden if we have parenthesis and", "start": 6663.88, "duration": 5.279 }, { "text": "inside we have another parenthesis and", "start": 6667.56, "duration": 3.559 }, { "text": "another parenthesis interfere with each", "start": 6669.159, "duration": 3.761 }, { "text": "other if you have parentheses inside of", "start": 6671.119, "duration": 4.641 }, { "text": "parenthesis that too is totally fine and", "start": 6672.92, "duration": 5.08 }, { "text": "indeed that should be one of the", "start": 6675.76, "duration": 5.08 }, { "text": "reassuring lessons today as complicated", "start": 6678.0, "duration": 4.4 }, { "text": "as each of these regular Expressions as", "start": 6680.84, "duration": 3.759 }, { "text": "it admittedly gotten I'm just applying", "start": 6682.4, "duration": 4.16 }, { "text": "the exact same principles and the exact", "start": 6684.599, "duration": 4.921 }, { "text": "same syntax again and again so it's", "start": 6686.56, "duration": 4.72 }, { "text": "totally fine to have parenthesis inside", "start": 6689.52, "duration": 3.28 }, { "text": "of parentheses if they're each solving", "start": 6691.28, "duration": 3.28 }, { "text": "different problems and in fact the", "start": 6692.8, "duration": 3.96 }, { "text": "lesson I would really emphasize the most", "start": 6694.56, "duration": 5.44 }, { "text": "today is that you will not be happy if", "start": 6696.76, "duration": 6.08 }, { "text": "you try to write out a whole complicated", "start": 6700.0, "duration": 5.0 }, { "text": "regular expression all at once like if", "start": 6702.84, "duration": 4.399 }, { "text": "you're anything like me you will fail", "start": 6705.0, "duration": 4.0 }, { "text": "and you will have trouble finding the", "start": 6707.239, "duration": 3.281 }, { "text": "mistake because my God look at these", "start": 6709.0, "duration": 3.639 }, { "text": "things they are even to me all these", "start": 6710.52, "duration": 4.48 }, { "text": "years later cryptic the better way I", "start": 6712.639, "duration": 4.0 }, { "text": "would argue whether you're new to", "start": 6715.0, "duration": 4.079 }, { "text": "programming or as old to it as I am is", "start": 6716.639, "duration": 5.0 }, { "text": "to just take these baby steps these", "start": 6719.079, "duration": 4.08 }, { "text": "incremental steps where you do something", "start": 6721.639, "duration": 3.401 }, { "text": "simple you make sure it works you add", "start": 6723.159, "duration": 4.121 }, { "text": "one more feature make sure it works add", "start": 6725.04, "duration": 4.28 }, { "text": "one more feature make sure it works and", "start": 6727.28, "duration": 3.52 }, { "text": "hopefully by the end because you've done", "start": 6729.32, "duration": 4.0 }, { "text": "each of those steps one at a time the", "start": 6730.8, "duration": 4.799 }, { "text": "whole thing will make sense to you but", "start": 6733.32, "duration": 3.96 }, { "text": "you'll also have gotten each of those", "start": 6735.599, "duration": 5.761 }, { "text": "steps correct um at each turn so please", "start": 6737.28, "duration": 6.959 }, { "text": "do avoid the inclination to try to come", "start": 6741.36, "duration": 4.64 }, { "text": "up with long sophisticated regular", "start": 6744.239, "duration": 3.4 }, { "text": "Expressions all at once because it's", "start": 6746.0, "duration": 3.8 }, { "text": "just not a good use of a time if you", "start": 6747.639, "duration": 3.52 }, { "text": "then stare at it trying to find a", "start": 6749.8, "duration": 3.0 }, { "text": "mistake that you could have caught if", "start": 6751.159, "duration": 3.361 }, { "text": "you did things more incrementally", "start": 6752.8, "duration": 3.64 }, { "text": "instead all right there Still Remains", "start": 6754.52, "duration": 4.0 }, { "text": "arguably at least one problem with this", "start": 6756.44, "duration": 3.84 }, { "text": "solution in that even though I'm calling", "start": 6758.52, "duration": 5.04 }, { "text": "re.sub to substitute the URL with", "start": 6760.28, "duration": 6.0 }, { "text": "nothing quote unquote I then on my final", "start": 6763.56, "duration": 4.599 }, { "text": "line of code line six I'm just blindly", "start": 6766.28, "duration": 3.68 }, { "text": "assuming that it all worked and I'm", "start": 6768.159, "duration": 3.321 }, { "text": "going to go ahead and print out the", "start": 6769.96, "duration": 3.96 }, { "text": "username but what if the user if I clear", "start": 6771.48, "duration": 3.88 }, { "text": "my screen here and run python of", "start": 6773.92, "duration": 4.159 }, { "text": "twitter. doesn't even type a Twitter URL", "start": 6775.36, "duration": 4.4 }, { "text": "what if they do something like", "start": 6778.079, "duration": 3.761 }, { "text": "https", "start": 6779.76, "duration": 4.04 }, { "text": "www.google.com like completely", "start": 6781.84, "duration": 5.44 }, { "text": "unrelatedly for whatever reason enter", "start": 6783.8, "duration": 5.52 }, { "text": "that is not their Twitter username so we", "start": 6787.28, "duration": 4.359 }, { "text": "need to have some conditional logic I", "start": 6789.32, "duration": 4.44 }, { "text": "would argue so that for this program's", "start": 6791.639, "duration": 5.0 }, { "text": "sake we're only printing out or in a", "start": 6793.76, "duration": 4.76 }, { "text": "backend system we're only saving into", "start": 6796.639, "duration": 4.56 }, { "text": "our database or a CSV file the username", "start": 6798.52, "duration": 4.96 }, { "text": "if we actually match matched the proper", "start": 6801.199, "duration": 5.681 }, { "text": "pattern so rather than use re.sub which", "start": 6803.48, "duration": 6.08 }, { "text": "is useful for cleaning up data as we've", "start": 6806.88, "duration": 4.4 }, { "text": "done here to get rid of something we", "start": 6809.56, "duration": 4.24 }, { "text": "don't want there why don't we go back to", "start": 6811.28, "duration": 6.56 }, { "text": "re. search where we began today and use", "start": 6813.8, "duration": 6.12 }, { "text": "it to solve the same problem but in a", "start": 6817.84, "duration": 4.04 }, { "text": "way that's conditional whereby I can", "start": 6819.92, "duration": 3.84 }, { "text": "confidently say yes or no at the end of", "start": 6821.88, "duration": 4.4 }, { "text": "my program here's the username or here", "start": 6823.76, "duration": 4.56 }, { "text": "it is not so let me go ahead now and", "start": 6826.28, "duration": 4.16 }, { "text": "I'll clear my terminal window here I'm", "start": 6828.32, "duration": 4.399 }, { "text": "going to keep most of uh the I'm going", "start": 6830.44, "duration": 4.12 }, { "text": "to keep the first two lines the same", "start": 6832.719, "duration": 4.081 }, { "text": "where I import re and I get the URL from", "start": 6834.56, "duration": 4.519 }, { "text": "the user but this time let's do this", "start": 6836.8, "duration": 5.12 }, { "text": "let's this time search for using re.", "start": 6839.079, "duration": 5.401 }, { "text": "search instead of re.sub the following", "start": 6841.92, "duration": 3.799 }, { "text": "I'm going to start matching at the", "start": 6844.48, "duration": 3.88 }, { "text": "beginning of the UR of the string", "start": 6845.719, "duration": 5.121 }, { "text": "https uh question mark to make the S", "start": 6848.36, "duration": 5.12 }, { "text": "optional colon SL slash then I'm going", "start": 6850.84, "duration": 4.96 }, { "text": "to make my uh", "start": 6853.48, "duration": 5.08 }, { "text": "www uh optional by putting that in", "start": 6855.8, "duration": 5.399 }, { "text": "question marks there then a twitter.com", "start": 6858.56, "duration": 4.599 }, { "text": "with a literal do there so I'll stay", "start": 6861.199, "duration": 5.4 }, { "text": "ahead of that issue too then a slash and", "start": 6863.159, "duration": 5.841 }, { "text": "then well this is where David J ma is", "start": 6866.599, "duration": 5.201 }, { "text": "supposed to go how do I detect this well", "start": 6869.0, "duration": 4.36 }, { "text": "I think I'll just tolerate anything at", "start": 6871.8, "duration": 4.6 }, { "text": "the end of the URL here all right dollar", "start": 6873.36, "duration": 5.68 }, { "text": "sign at the very end close quote for the", "start": 6876.4, "duration": 4.08 }, { "text": "moment I'm going to stipulate that we're", "start": 6879.04, "duration": 3.159 }, { "text": "not going to worry about question marks", "start": 6880.48, "duration": 4.0 }, { "text": "at the end or hashes like for fragment", "start": 6882.199, "duration": 4.241 }, { "text": "IDs and URLs we're going to assume for", "start": 6884.48, "duration": 4.4 }, { "text": "Simplicity now that the URL just ends", "start": 6886.44, "duration": 5.08 }, { "text": "with the username alone now what am I", "start": 6888.88, "duration": 4.319 }, { "text": "going to do well I want search for this", "start": 6891.52, "duration": 3.52 }, { "text": "URL specifically and I'm going to ignore", "start": 6893.199, "duration": 5.52 }, { "text": "case so re. ignore case uh applying that", "start": 6895.04, "duration": 6.52 }, { "text": "same lesson learned from before re.", "start": 6898.719, "duration": 5.641 }, { "text": "search recall will return to you the", "start": 6901.56, "duration": 4.519 }, { "text": "matches you've captured well what do I", "start": 6904.36, "duration": 3.719 }, { "text": "want to capture well I want to capture", "start": 6906.079, "duration": 4.481 }, { "text": "everything to the right of the", "start": 6908.079, "duration": 5.56 }, { "text": "twitter.com URL here so let me surround", "start": 6910.56, "duration": 6.039 }, { "text": "what should be the user's username with", "start": 6913.639, "duration": 5.44 }, { "text": "parentheses not for making them optional", "start": 6916.599, "duration": 4.201 }, { "text": "but to say capture this set of", "start": 6919.079, "duration": 4.801 }, { "text": "characters now are search recall returns", "start": 6920.8, "duration": 5.399 }, { "text": "and answer matches will be my variable", "start": 6923.88, "duration": 3.799 }, { "text": "name again but I could call it anything", "start": 6926.199, "duration": 5.52 }, { "text": "I want and then I can do this if matches", "start": 6927.679, "duration": 6.44 }, { "text": "now I know I can do this let's print out", "start": 6931.719, "duration": 5.36 }, { "text": "the format string username colon and", "start": 6934.119, "duration": 6.241 }, { "text": "then uh what do I want to print out well", "start": 6937.079, "duration": 5.361 }, { "text": "I think I want to print out matches.", "start": 6940.36, "duration": 5.56 }, { "text": "group one for my matched username all", "start": 6942.44, "duration": 5.6 }, { "text": "right so what am I doing just to recap", "start": 6945.92, "duration": 4.239 }, { "text": "line one I'm importing the library line", "start": 6948.04, "duration": 4.32 }, { "text": "two I'm getting the URL from the user so", "start": 6950.159, "duration": 4.881 }, { "text": "nothing new there line five I'm", "start": 6952.36, "duration": 5.92 }, { "text": "searching the user's URL as indicated", "start": 6955.04, "duration": 5.76 }, { "text": "here as the second argument for this", "start": 6958.28, "duration": 5.399 }, { "text": "regular expression this pattern I have", "start": 6960.8, "duration": 7.12 }, { "text": "surrounded the dot plus with parentheses", "start": 6963.679, "duration": 6.601 }, { "text": "so that they are captured ultimately so", "start": 6967.92, "duration": 5.12 }, { "text": "I can extract in this final scenario the", "start": 6970.28, "duration": 5.879 }, { "text": "user's username if I indeed got a match", "start": 6973.04, "duration": 6.4 }, { "text": "and matches is non none it is actually", "start": 6976.159, "duration": 5.801 }, { "text": "containing some match then and only then", "start": 6979.44, "duration": 5.159 }, { "text": "print out username in this way let me", "start": 6981.96, "duration": 5.279 }, { "text": "try this now if I run python of twitter.", "start": 6984.599, "duration": 5.841 }, { "text": "and type in HTTPS", "start": 6987.239, "duration": 6.081 }, { "text": "www.google.com now nothing gets printed", "start": 6990.44, "duration": 4.84 }, { "text": "so I've at least solved the mistake we", "start": 6993.32, "duration": 3.839 }, { "text": "just saw where I was just assuming that", "start": 6995.28, "duration": 4.399 }, { "text": "my code worked now I'm making sure that", "start": 6997.159, "duration": 4.801 }, { "text": "I have searched for and found the", "start": 6999.679, "duration": 5.121 }, { "text": "Twitter URL prefix all right well let's", "start": 7001.96, "duration": 6.639 }, { "text": "run this for real now python of twitter.", "start": 7004.8, "duration": 7.76 }, { "text": "https twitter.com davidj maen but note I", "start": 7008.599, "duration": 7.401 }, { "text": "could use HTTP I could use www I'm just", "start": 7012.56, "duration": 5.639 }, { "text": "going to go ahead here and hit", "start": 7016.0, "duration": 4.92 }, { "text": "enter huh", "start": 7018.199, "duration": 6.321 }, { "text": "none what has gone", "start": 7020.92, "duration": 6.279 }, { "text": "wrong this one's a bit more", "start": 7024.52, "duration": 6.92 }, { "text": "subtle but why does matches. group one", "start": 7027.199, "duration": 6.761 }, { "text": "contain nothing wait a minute let me", "start": 7031.44, "duration": 4.759 }, { "text": "maybe I maybe I did this wrong maybe", "start": 7033.96, "duration": 4.239 }, { "text": "maybe do we need the www let me run it", "start": 7036.199, "duration": 4.96 }, { "text": "again so here we go https let's add it", "start": 7038.199, "duration": 9.361 }, { "text": "www. twitter.com davidj maen all right", "start": 7041.159, "duration": 6.401 }, { "text": "enter what is going on we have to say", "start": 7047.88, "duration": 6.96 }, { "text": "group two I have to say group two well", "start": 7051.8, "duration": 5.319 }, { "text": "wait all right because we had the the", "start": 7054.84, "duration": 5.0 }, { "text": "subdomain was optional and to make it", "start": 7057.119, "duration": 4.96 }, { "text": "optional I needed to use parentheses", "start": 7059.84, "duration": 4.72 }, { "text": "here and so I then said zero or one okay", "start": 7062.079, "duration": 5.761 }, { "text": "so that means that actually I'm", "start": 7064.56, "duration": 5.92 }, { "text": "unintentionally but by Design capturing", "start": 7067.84, "duration": 5.48 }, { "text": "the www do or none of it if it wasn't", "start": 7070.48, "duration": 5.639 }, { "text": "there before but I have a second match", "start": 7073.32, "duration": 4.08 }, { "text": "over here because I have a second set of", "start": 7076.119, "duration": 2.96 }, { "text": "parentheses so I think yep let me change", "start": 7077.4, "duration": 4.04 }, { "text": "matches group one to matches group two", "start": 7079.079, "duration": 5.52 }, { "text": "and let's rerun this python of twitter.", "start": 7081.44, "duration": 7.639 }, { "text": "https www. Twitter let's do this uh", "start": 7084.599, "duration": 9.321 }, { "text": "twitter.com davidj maen enter and now", "start": 7089.079, "duration": 7.12 }, { "text": "we've got access to the username let me", "start": 7093.92, "duration": 4.199 }, { "text": "go ahead and tighten it up a little bit", "start": 7096.199, "duration": 5.241 }, { "text": "further uh if you like uh our new friend", "start": 7098.119, "duration": 4.881 }, { "text": "uh it's hard not to like if we like our", "start": 7101.44, "duration": 4.239 }, { "text": "old friend The Walrus uh operator let's", "start": 7103.0, "duration": 4.199 }, { "text": "go ahead and add this just to tighten", "start": 7105.679, "duration": 3.721 }, { "text": "things up let me go back to vs code here", "start": 7107.199, "duration": 3.96 }, { "text": "and let me get rid of the unnecessary", "start": 7109.4, "duration": 3.279 }, { "text": "condition there and combine it up here", "start": 7111.159, "duration": 4.321 }, { "text": "if matches equals that but let's change", "start": 7112.679, "duration": 4.321 }, { "text": "the single assignment operator to the", "start": 7115.48, "duration": 3.44 }, { "text": "Wallace operator now I've tightened", "start": 7117.0, "duration": 4.639 }, { "text": "things up further but I bet I bet I bet", "start": 7118.92, "duration": 5.279 }, { "text": "there might be another solution here and", "start": 7121.639, "duration": 5.641 }, { "text": "indeed it turns out that we can come", "start": 7124.199, "duration": 6.841 }, { "text": "back to this final set of syntax recall", "start": 7127.28, "duration": 4.879 }, { "text": "that when we introduced these", "start": 7131.04, "duration": 2.72 }, { "text": "parentheses we did it so that we could", "start": 7132.159, "duration": 4.201 }, { "text": "do a or b for instance with the vertical", "start": 7133.76, "duration": 4.16 }, { "text": "bar though you can even combine more", "start": 7136.36, "duration": 4.08 }, { "text": "than just one bar we used the group to", "start": 7137.92, "duration": 5.319 }, { "text": "combine ideas like the www dot and then", "start": 7140.44, "duration": 5.279 }, { "text": "there's this admittedly weird syntax at", "start": 7143.239, "duration": 5.561 }, { "text": "the bottom here up until now not used", "start": 7145.719, "duration": 5.761 }, { "text": "there is a non- capturing version of", "start": 7148.8, "duration": 4.08 }, { "text": "parentheses if you want to use", "start": 7151.48, "duration": 3.04 }, { "text": "parentheses logically because you need", "start": 7152.88, "duration": 3.88 }, { "text": "to but you don't want to bother", "start": 7154.52, "duration": 4.28 }, { "text": "capturing the result and this would", "start": 7156.76, "duration": 3.919 }, { "text": "arguably be a better solution here", "start": 7158.8, "duration": 4.799 }, { "text": "because yes if I go back to s code I do", "start": 7160.679, "duration": 5.761 }, { "text": "need to surround the www do with", "start": 7163.599, "duration": 4.681 }, { "text": "parentheses at least as I've written my", "start": 7166.44, "duration": 4.08 }, { "text": "Rex here because I wanted to put the", "start": 7168.28, "duration": 4.6 }, { "text": "question mark after it but I don't need", "start": 7170.52, "duration": 5.159 }, { "text": "the www dot coming back in fact let's", "start": 7172.88, "duration": 4.839 }, { "text": "only extract the data we care about just", "start": 7175.679, "duration": 3.96 }, { "text": "so there's no confusion down the road", "start": 7177.719, "duration": 4.44 }, { "text": "for me or my colleagues or my teachers", "start": 7179.639, "duration": 5.52 }, { "text": "so what could I do well the syntax per", "start": 7182.159, "duration": 5.52 }, { "text": "this slide is to use a question mark and", "start": 7185.159, "duration": 5.44 }, { "text": "a colon immediately after the open", "start": 7187.679, "duration": 5.321 }, { "text": "parenthesis it looks weird admittedly", "start": 7190.599, "duration": 4.0 }, { "text": "those of you who have prior programming", "start": 7193.0, "duration": 3.199 }, { "text": "experience might recognize the syntax", "start": 7194.599, "duration": 4.04 }, { "text": "from Turner operators doing an if else", "start": 7196.199, "duration": 5.721 }, { "text": "allinone line a question mark colon at", "start": 7198.639, "duration": 5.52 }, { "text": "the beginning of that parenthetical", "start": 7201.92, "duration": 5.159 }, { "text": "means yes I'm using parentheses to group", "start": 7204.159, "duration": 5.361 }, { "text": "these things together but no you do not", "start": 7207.079, "duration": 5.0 }, { "text": "need to capture them instead so I can", "start": 7209.52, "duration": 4.88 }, { "text": "change my code back now to matches.", "start": 7212.079, "duration": 4.721 }, { "text": "group one I'll clear my screen here run", "start": 7214.4, "duration": 5.719 }, { "text": "python of twitter. I'll again run here", "start": 7216.8, "duration": 4.16 }, { "text": "uh", "start": 7220.119, "duration": 4.761 }, { "text": "https twitter.com davidj maen with or", "start": 7220.96, "duration": 7.56 }, { "text": "without the www and now I indeed get", "start": 7224.88, "duration": 8.08 }, { "text": "back that username any questions then on", "start": 7228.52, "duration": 7.76 }, { "text": "these final", "start": 7232.96, "duration": 6.48 }, { "text": "techniques so first well could we move", "start": 7236.28, "duration": 5.28 }, { "text": "the carrot right at the beginning of", "start": 7239.44, "duration": 4.56 }, { "text": "Twitter and then just start reading from", "start": 7241.56, "duration": 4.119 }, { "text": "there and then get rid of everything", "start": 7244.0, "duration": 4.159 }, { "text": "else before that the kind of", "start": 7245.679, "duration": 5.681 }, { "text": "WWE uh issues that we had and then my", "start": 7248.159, "duration": 6.321 }, { "text": "second question is how would we um use", "start": 7251.36, "duration": 6.719 }, { "text": "kind of I guess it either a list or a a", "start": 7254.48, "duration": 6.56 }, { "text": "dictionary to to sort the dotom kind of", "start": 7258.079, "duration": 6.16 }, { "text": "thing if because we have Cod UK and that", "start": 7261.04, "duration": 6.079 }, { "text": "kind of s how would we bring that into", "start": 7264.239, "duration": 5.161 }, { "text": "uh the re function a good question but", "start": 7267.119, "duration": 4.6 }, { "text": "no if I move the carrot before", "start": 7269.4, "duration": 4.64 }, { "text": "twitter.com and throw away the protocol", "start": 7271.719, "duration": 5.081 }, { "text": "and the www then the user is going to", "start": 7274.04, "duration": 5.119 }, { "text": "have to type in literally", "start": 7276.8, "duration": 5.2 }, { "text": "twitter.com username they can't even", "start": 7279.159, "duration": 4.121 }, { "text": "type in that other stuff so that would", "start": 7282.0, "duration": 3.84 }, { "text": "be a regression a step back as for the", "start": 7283.28, "duration": 5.839 }, { "text": "do and the.org and.edu and so forth the", "start": 7285.84, "duration": 5.0 }, { "text": "short answer is there's many different", "start": 7289.119, "duration": 3.921 }, { "text": "solutions here if I wanted to be", "start": 7290.84, "duration": 4.92 }, { "text": "stringent about do and suppose that", "start": 7293.04, "duration": 4.84 }, { "text": "Twitter probably owns multiple domain", "start": 7295.76, "duration": 4.16 }, { "text": "names even though they tend to use just", "start": 7297.88, "duration": 4.4 }, { "text": "this one suppose they have uh something", "start": 7299.92, "duration": 4.52 }, { "text": "like.org as well you could use more", "start": 7302.28, "duration": 3.52 }, { "text": "parentheses here and do something like", "start": 7304.44, "duration": 4.4 }, { "text": "this Comm or org I'd probably want to go", "start": 7305.8, "duration": 5.12 }, { "text": "in and add a question mark colon to make", "start": 7308.84, "duration": 3.96 }, { "text": "it non-capture because I don't care", "start": 7310.92, "duration": 4.92 }, { "text": "which it is I just want to tolerate both", "start": 7312.8, "duration": 5.52 }, { "text": "alternatively we could capture that we", "start": 7315.84, "duration": 4.319 }, { "text": "could do something like this where we do", "start": 7318.32, "duration": 5.24 }, { "text": "do plus so as to actually capture that", "start": 7320.159, "duration": 5.52 }, { "text": "and then we could do something like this", "start": 7323.56, "duration": 7.72 }, { "text": "if matches. group one now equals equals", "start": 7325.679, "duration": 8.081 }, { "text": "Comm then we could support this so you", "start": 7331.28, "duration": 4.839 }, { "text": "could imagine factoring out the logic", "start": 7333.76, "duration": 4.479 }, { "text": "just by extracting the top level domain", "start": 7336.119, "duration": 4.441 }, { "text": "or TLD and then just using python code", "start": 7338.239, "duration": 4.0 }, { "text": "maybe a list maybe a dictionary to", "start": 7340.56, "duration": 4.44 }, { "text": "validate elsewhere outside of the redx", "start": 7342.239, "duration": 5.081 }, { "text": "if it's in fact what you expect for now", "start": 7345.0, "duration": 4.28 }, { "text": "though we kept things simple we focused", "start": 7347.32, "duration": 4.879 }, { "text": "only on the Doom in this case let's make", "start": 7349.28, "duration": 4.6 }, { "text": "one final change to this program so that", "start": 7352.199, "duration": 3.241 }, { "text": "we're being a little more specific with", "start": 7353.88, "duration": 3.799 }, { "text": "the definition of a Twitter username it", "start": 7355.44, "duration": 3.719 }, { "text": "turns out that we're being a little too", "start": 7357.679, "duration": 3.281 }, { "text": "generous over here whereby we're", "start": 7359.159, "duration": 4.161 }, { "text": "accepting one or more of any character I", "start": 7360.96, "duration": 4.32 }, { "text": "check the documentation for Twitter and", "start": 7363.32, "duration": 3.839 }, { "text": "Twitter only supports letters of the", "start": 7365.28, "duration": 5.72 }, { "text": "alphabet A through Z numbers 0-9 or", "start": 7367.159, "duration": 6.44 }, { "text": "underscores so not just dot which is", "start": 7371.0, "duration": 4.92 }, { "text": "literally anything so let me go ahead", "start": 7373.599, "duration": 4.12 }, { "text": "and be more precise here at the end of", "start": 7375.92, "duration": 5.0 }, { "text": "my string let me go ahead and say this", "start": 7377.719, "duration": 5.801 }, { "text": "set of symbols in square brackets I'm", "start": 7380.92, "duration": 4.92 }, { "text": "going to go ahead and say a through z uh", "start": 7383.52, "duration": 4.88 }, { "text": "0 through 9 and an underscore because", "start": 7385.84, "duration": 4.279 }, { "text": "again those are the only valid symbols I", "start": 7388.4, "duration": 3.36 }, { "text": "don't need to bother with an uppercase a", "start": 7390.119, "duration": 4.361 }, { "text": "or a lowercase z because we're using re.", "start": 7391.76, "duration": 5.08 }, { "text": "ignore case over here but I want to make", "start": 7394.48, "duration": 4.84 }, { "text": "sure now that I tolerate not only one or", "start": 7396.84, "duration": 5.12 }, { "text": "more of these symbols here but also", "start": 7399.32, "duration": 4.319 }, { "text": "maybe some other stuff at the end of the", "start": 7401.96, "duration": 3.56 }, { "text": "URL I'm now going to be okay with there", "start": 7403.639, "duration": 4.281 }, { "text": "being a slash or a question mark or a", "start": 7405.52, "duration": 4.44 }, { "text": "hash at the end of the URL all of which", "start": 7407.92, "duration": 4.52 }, { "text": "are valid symbols in a URL but I know", "start": 7409.96, "duration": 4.92 }, { "text": "from the Twitter's documentation are not", "start": 7412.44, "duration": 4.719 }, { "text": "part of the username all right now I'm", "start": 7414.88, "duration": 3.719 }, { "text": "going to go ahead and run python of", "start": 7417.159, "duration": 5.241 }, { "text": "twitter. one final time typing in", "start": 7418.599, "duration": 5.56 }, { "text": "HTTPS", "start": 7422.4, "duration": 4.679 }, { "text": "twitter.com davidj ma maybe with maybe", "start": 7424.159, "duration": 4.881 }, { "text": "without a trailing slash but hopefully", "start": 7427.079, "duration": 3.961 }, { "text": "with my biggest fingers crossed here I'm", "start": 7429.04, "duration": 4.519 }, { "text": "going to go ahead now and hit enter and", "start": 7431.04, "duration": 5.039 }, { "text": "thankfully my username is indeed David J", "start": 7433.559, "duration": 4.801 }, { "text": "Ma so what more is there in the world of", "start": 7436.079, "duration": 4.241 }, { "text": "regular expressions and this own Library", "start": 7438.36, "duration": 4.359 }, { "text": "not just re. search and also re.sub", "start": 7440.32, "duration": 4.64 }, { "text": "there's other functions too there's re", "start": 7442.719, "duration": 4.761 }, { "text": "dosit via which you can split a string", "start": 7444.96, "duration": 4.48 }, { "text": "not using a specific character or", "start": 7447.48, "duration": 4.36 }, { "text": "characters like a comma and a space but", "start": 7449.44, "duration": 5.0 }, { "text": "multiple characters as well and there's", "start": 7451.84, "duration": 4.799 }, { "text": "even functions like re. findall which", "start": 7454.44, "duration": 4.679 }, { "text": "can allow you to search for multiple", "start": 7456.639, "duration": 4.321 }, { "text": "copies of the same pattern in different", "start": 7459.119, "duration": 3.761 }, { "text": "places in a Str so that you can perhaps", "start": 7460.96, "duration": 4.48 }, { "text": "and manipulate more than just one so at", "start": 7462.88, "duration": 4.0 }, { "text": "the end of the day now you've really", "start": 7465.44, "duration": 3.799 }, { "text": "learned a whole other language like that", "start": 7466.88, "duration": 4.08 }, { "text": "of regular expressions and we've used", "start": 7469.239, "duration": 3.0 }, { "text": "them in Python but these regular", "start": 7470.96, "duration": 3.719 }, { "text": "Expressions actually exist in so many", "start": 7472.239, "duration": 5.0 }, { "text": "languages too among them JavaScript and", "start": 7474.679, "duration": 5.44 }, { "text": "Java and Ruby and more so with this new", "start": 7477.239, "duration": 4.681 }, { "text": "language even though it's admittedly", "start": 7480.119, "duration": 3.321 }, { "text": "cryptic when you use it for the first", "start": 7481.92, "duration": 3.239 }, { "text": "time you have this new found ability to", "start": 7483.44, "duration": 3.639 }, { "text": "express these patterns that again you", "start": 7485.159, "duration": 4.4 }, { "text": "can use to validate data to clean up", "start": 7487.079, "duration": 5.441 }, { "text": "data or even extract data and from any", "start": 7489.559, "duration": 5.241 }, { "text": "data set you might have in mind that's", "start": 7492.52, "duration": 4.48 }, { "text": "it for this week we will see you next", "start": 7494.8, "duration": 5.2 }, { "text": "time", "start": 7497.0, "duration": 3.0 } ]