Python for Informatics – Chapter 11 – Regular Expressions



Hello and welcome to chapter
11, regular expressions from the book Python
for Informatics, Exploring Information. As always, these slides are
copyright Creative Commons attribution as well
as the audio and video that you're watching or
listening to right now. So regular expressions
are an interesting thing. You've seen from the
chapters up til now, I've had a singular focus
on pulling information out of data. Raw data, this mailbox
file that perhaps you're getting tired of already. But it's a lot of
fun, because I can have you go look for
something and pick it out and you're doing
something that would be really painful to do by hand. And while it's not all about
computing, there's games and there's things like
weather computations that do calculations,
pulling extracting data out is a big part of computing. And so there's actually
a library that's built specifically do this. And if you start doing
a few finds and slicing, it gets long after a while. Like split, for example,
really saved us a lot of time. But sometimes, the data
that you're looking for is a little more
sophisticated than broken into spaces or colons
or something like that. And you just want to tell
something to go find, I see what I want
and I see where it's embedded in the
string, go get it for me. And regular expressions are
themselves a programming language. They're like a really smart
wild card for searching. So we've used wild cards in
various things in search. But they are a really smart
version of a wild card. And so regular expressions
are quite powerful. And they're very cryptic. And as a matter of
fact, you don't even need to learn them if you
don't feel like it, right? I've got this little guide. I need a guide for myself
when I do regular expressions. It sometimes takes
me a few minutes to write a regular expression
to do exactly what I want. So in a way, writing
a regular expression is like writing a program. It's highly specialized to
searching and extracting data from strings, but it's
like writing a program. And it takes a while
to get it right. And you have to change this,
what about a slash there. But they actually are fun. And they're a great way
to exchange little program snippets to say, oh yeah,
I'm looking for this. Oh, here's a little reg
expression you might try. So they're like
programs themselves. It is this language
of marker characters. So when we look for
regular expressions, some characters like
ABC, have meaning as ABC. But some characters, like
carrot or dollar sign mean the beginning of the line
or at the end of the line. And so we encode, in this
string, a program, basically. So it's a rather
old school language. It's from a long time. It predates Python, which
is over 20 years old. It also marks you as
a little cool, right? It's a distinct marking that
makes it so that you know something other people don't. So you can know how to program. But if you know regular
expressions, they'll be like, whoa, I tried to look at
those and they're tough. In a way, knowing regular
expressions is like a tattoo. So it's casual Friday. And that's why I'm
wearing a t-shirt today and so I figured I would
come in today in a t-shirt. But seeing as how
it's the first I'm wearing a short
sleeved shirt, it's also first time I can show
you my real tattoo here. So here's my real tattoo. And in the middle is the
Sakai, the open source learning manager system,
always close to my heart. And then you have
the IMS logo, which is IMS Learning Tools
and Operability, which is a standard that
means a lot to me. Blackboard, OLAT, Learning
Objects, Angel, Moodle, Instructure, Jenzabar,
and Desire2Learn. I call this the
ring of compliance. Because these are all of the
first six or seven learning management systems that complied
with the IMS Learning Tools Interoperability Standard
and Specification, which is something that I spent
a lot of my life making work. So I figured I'd make
a tattoo and just a part of my rough, tough image. And actually,
regular expressions are indeed part of my
rough, tough image. Because I'm like, I'm down
with regular expressions. And people are like, impressed
with my regular expression knowledge. But as impressive as I am,
I still need a cheat sheet. So I'll have a cheat sheet that
you can download, hopefully, on the Python [INAUDIBLE]
website or whatever. And it doesn't have to be much. It's really just a crutch. And these are the characters
that have special meaning. Like carrot or dollar sign match
the beginning or end of line, respectively. So they're not really
matching a dollar sign, they match– they mean something
in our little mini string like programming language. So like many things that we
do in Python going forward, once you want some
sophisticated capability, it comes with Python, but it
comes in the form of a library. And so the regular
expression library, we have to say import RE at
the beginning of our programs to import to regular
expression library. Then we call
RE.search to say I'm looking for search from the
regular expression library. There's two basic
basic capabilities inside this library that
we're going to look at. One is search that
replaces find. It's like a smart find. And then find all is a
combination of a smart find and automatic extraction. So we'll look at both
of those in turn. And I'll do it by comparing
them to existing Python that you already should
know at this point. So here's some code that's,
say, looking for lines that have the string from colon in them. So we're going to
open a file, we're going to strip the white
space, if we find– if we hunt within
line for from, if it's greater than or equal to
zero, then we'll print it. And so this is just going
to give us a number. If it's not found,
it's negative 1. So it's only going to print
the lines that from in them. Here is the equivalent
using regular expressions. So these two things
are equivalent. So we have to import to library,
like I mentioned before. And all the rest
of it's the same. The IF test is RE.search that
says, within the library, RE, called the Search Utility. And then pass in the
string we're looking for and the line, the actual
text we're looking in. So this is like look for from
inside of line and return me a true or false,
whichever depending on whether you find it or not. Now, might say, you
just got done telling me that it was more dense. And the answer is, there's
a few more characters here. But we'll see in a second how
you can quickly add more power to the regular expression. Find you have to start adding
more Python lines to make it more sophisticated where
in the regular expression, you start changing– you change
the search string to give more of the direction of
what you're looking for. And that's what we'll
be doing pretty much is changing the search string. So now, if we want to switch
to, say, wait, wait, wait, we don't just want the
from anywhere in the line. We want it to start with from. So we would change
line.startswith('From'). And that's either going to
be true or false depending on whether or not the
line starts with from. Now, we do the same thing
with regular expressions by changing the search string. So now we're in
regular expressions. So this really just
isn't a string. It's a string plus
characters that are interpreted as commands by
the regular expression library. So the caret, which is the first
one on our regular expressions sheet, matches the
beginning of the line. It's not actually a caret. So that says, the first
character, this two character sequence, caret f means
f but in column one in the first
character of the line. So again, this is going
to give us a true or false if this regular
expression matches. The beginning of the line from:
and it's the same as this. It's, does it start with from? So again, these
two are equivalent. But you see the
pattern where we're going to do something to this
string using these characters that have meaning, OK? So the next thing
that's most commonly done other than caret and
dollar sign for the end of line is the wild card characters. And so we use cards
possibly in like DOS where we can use
question mark or star in like a dir command or
dir dot star dot star if you're familiar with that
or even a Unix command like ls, you know, star dot whatever. This is not how regular
expressions work. And the problem is
that dot, dot is– it matches a single character
in regular expressions. Asterisk means any
number of times. So if I look at this
and color code this to make a little
more sense, the caret is actually kind of part of the
regular expression programming language. Says, I'm a virtual character
matching the beginning of line. The x is a real character. The dot is part of the
regular programming language– any character. Star is part of the regular
expression programming that says the immediate previous
character many times s– 0 or more times. And then colon
matches the colon. And so if you look
at lines, these are the kinds of lines that
will give me a true because they start with an x followed by some
number of characters followed by colon. So that's true. Start with x followed by
some number of characters followed by colon. OK, and so that's
basically how this works. And so this five
character string, there are– some of these
things are like instructions and some of them are the actual
characters were looking for. So the x and the colon are the
characters we're looking for and the caret, dot, and
star are programming, right? They are logic that we're
adding to the string. OK, so let's say for example
you're– part of any of these things and part of the stuff
we've done so far has to assume that the data is some
level of being clean. And so the data that
I've been giving you in boxed up TXT is
not inconsistent. It doesn't have, like,
too much weirdness in it. I'm not trying to trick
you and mislead you although we had situations where
you sort of get a trace back because you think there's
going to be five words. You grab a line, you break it,
and there's only two words. And you get a trace
back because you're looking at the fifth word
or something like that. But if your data is less
clean or even if you just want to be real careful, you
can fine tune your matching. So here's that same match. Give me a character x followed
by any number of characters followed by a colon. And that's what I'm looking for. Give me lines that
match that pattern. So this x starts at any
number of characters. Colon, great. That's any number of
characters– great. Oh wait, and there's
an email that says x plane is two weeks
behind schedule colon two weeks. Well, the regular
expression didn't know that dash made
sense to you and you just assumed that everything
that started with a capital x had a dash after it. So x is what it starts with–
any number of any character– and then a colon. So this becomes true. This may not make you happy. It may not be what
you're looking for because you haven't
been specific enough in your regular expression. So we can be more specific
in our regular expression. So for example, this is a more
specific regular expression. It still says start with an
x as the first character, then a dash– that's
a real character, not a– then this next thing,
instead of being a dot, it's backslash capital
S. It's on the sheet. Oh, it's not on the sheet. I lost the sheet. Come back, sheet. I lost the sheet. I can't live without my sheet. Backslash capital S means
a non-whitespace character. So that means
spaces won't match. And then I change
the asterisk zero or more times thing to a plus. And that means
one or more times. Here's a character, a
non-whitespace– these two things kind of work together–
a non-whitespace character at least one time as many
as we like and then a colon. So if we look here,
it starts with x dash any number of
non-whitespace characters and ends in colon–
starts with x dash any number of caret
characters, ends in a colon. True, true. This one starts with an x but
doesn't start with an x dash. As a matter of fact, these
characters are blanks. So this becomes a false. It does have an x
and does have a colon and matched the previous one. But this one here
is more specific. OK, so it's more specific. And so it matches what you want. Now, it depends on what
you're looking for. Maybe you do want this line
and so you're looking for x. I don't know. But if you want, you
can be increasingly sophisticated in
what you're looking for in a regular expression. So now let's talk
about extracting data. So everything we've done so far
is, is it there or is it not? But it's really common
once you find something that you want to
break it into pieces. So we can combine the
searching and the parsing into one statement. And instead of
using search, which returns for us a true false,
we're going to use find all. So in this example, I'm going
to show you a new syntax. The square bracket, in
regular expression language, means a way to list
a set of characters. So this says– this is a
single character that says, I want to match anything in
the range zero through nine. Plus means one or more of those. So that says– so this whole
thing says one or more digits. That's a regular expression
that says one or more digits. You can put other
things inside here. You can put, like– you could
make a thing that says a, b, c, d. And that would say, I'm going to
match a single character that's a or b or c or d. Or you could say,
like, 1357 bracket. That's a single character
that's either a one or a three or a five or a seven. So the bracket is a list
of matching characters in the dash inside the
bracket– means range. We'll see in a
second that you can stick a not inside the bracket. It's on the sheet. So again, remember– in
this little mini language, we are programming, right? We are giving instructions
to the regular expression engine as it were, OK? So if we do this– and here
is an expression that says, I would like to find things
that are one or more digits. And so it's one or more digits. And so it's going
to look through here and it's going to find it
as many times as it can. So there is one or more digits. There is one or more digits. And there is one or more digits. And so what find all gives
us back is a list of strings. So it found it. Where do I match? Where do I match? Where– it's looking
the whole time. And then it says, oh,
I've got it– 2, 19, 42. So it actually extracts
the strings that match and gives you a Python list
of strings– Python list of strings. Kind of like split except
it's like a super smart split, right? It's split, but I've
directed it what to look for. And if– so here's an example
of– that's what I just did. Find me one or more
digits and then extract them– so 2, 19, 42. Here I'm saying using
the same bracket syntax to look for a single character,
a capital A, E, I, O, or U, and one or more of those. And if you look, there are no
uppercase vowels in my string. So it says I want to
find all the things that match A, E, I, O, U. So
things like AA would match and, you know, OU would match. And so that's what we would
get if they were in the string. But because there are none,
we get an empty string. So even if there are none,
you get an empty string. So it always returns a string. It may be a zero length string. And that's what you
have to check, OK? OK, now, matching has
this notion of greedy where when you put one of
these pluses or asterisks, it kind of has this outward
pushing feeling, right? And so when you say I'm
looking for something that starts with an F at the
beginning of the line followed by one or more characters
followed by a colon, you can think of this
as pushing outward. So if we look at a line
here that has from colon using the colon character,
it will try to expand. So it certainly has to match the
F. And it's looking for a colon any number of characters. But it's trying to
make the string that matches as big as possible. So it skips over this colon
and goes to that colon. And so the thing
that we get is here. And so it ignored this and said,
I will make as large a string as I can. So that's the plus
that's doing it. Dot plus pushes. It's like, I got a colon, but is
there another colon out there? So push it. OK, so that's a greedy matching. It can get you in some trouble
like being greedy in general. And both asterisk and plus
sort of behave in a greedy way because they're zero or more
or one or more characters. So they can sort
of push outward. OK, now you can turn this off. It's a programming language. We can tweak it, OK? And so we add a question mark. So this is a three
character sequence now. So if you say dot plus question
mark, that says one or more of any characters
push– but instead of being greedy and
pushing as far as you can, this means stop at the first. Stop at the first. Oops– stop at the first. I can never draw on
this thing fast enough. Stop at the first, OK? And that's it. Just don't be greedy. Don't try to make the
string as large as possible. Go with the smaller one–
the smaller possible one. We still need to find an F and
we still need to find a colon. But when you find the
first colon, stop. And so what this does
is this changes it so that what we
match is from colon instead of going all the way. So the greedy match
pushes as far as it can. The non greedy
match is satisfied with the first thing that meets
the criterion of the string. So this is a little three
character programming sequence– any character one
or more times and not greedy. If, for example, we were trying
to solve the problem of pulling the email address
out of a string, we can make good use of
this non blank character. And so the at sign
is just a character. And then we can say,
I want at least one non blank character
before it and at least one non blank
character after it. So the way regular
expressions does, it says, OK. I find my at sign and I push
in a greedy manner outwards as long as they're
non blank characters. Push, push, push, push, push,
push, push, whoops, stop. Push, push, push,
push, push, stop. OK, so it's some number of non
blank characters, an at sign, followed by some number
of non blank characters. So that's using greedy matching. Its doing that, OK? And so this is where we
get Stephen Marquard. And we would know if it wasn't
there by the empty list, right? And so we get
[email protected] Now, we can also fine tune
what we extract, right? In the previous
slide, we extracted whatever matched, right? Whatever this matched, it
looked across the whole string and found it. It found the thing,
shoved it over, and gave us what it matched. But it's possible to
make the match larger than what's extracted to
extract a subset of the match. And we'll see that on
this next slide OK? So here's this same
thing, which is an at and then with non blank
characters as far as the eye can see in either direction. But I'm going to add
to it caret from space. So this has to start with–
the first character is to be a caret. It's got to have the word from. It's got to have one space. And then immediately, it's
got to find this, right? It's got to find a series
of non blanks followed by an and sign followed
by another series of one or more non blanks. And then what we
do– so if we didn't put these parentheses
in, it would match and we would get
all of this data. It would go to here. But what we can do with the
parentheses– the parentheses are part of the regular
expression language– saying, OK, I want to match
the whole thing. The parentheses aren't
part of the string up here. I want to match the
whole thing but I only want to extract this
part in parentheses. So this whole thing is a regular
expression that's matched. And then the parentheses part
is what's retrieved for you. And so this makes it
so that the only time it's going to look for
at signs are on lines that start with from space. It is going to want the
immediate next character to be a non blank, some number
of non-white characters, followed by an at sign, some
number of non blank characters. It's going to stop right there. And it's only going to
extract from here to here. So we get out Stephen Marquard. But this is a pretty
narrowly scoped thing because the first
four characters have to be from space. And so that's a way
to combine a stricter match even though you don't
actually want all the data. So you can add those things
all over the place, OK? OK, then we can compare
the different ways of extracting data. So if we look at how we
extract the hostname. Remember how we did
this many chapters ago. So we did a data dot find which
says, oh, the first at sign is a 21. So the first one is a 21. Then we say, we want to
find the space after that. So that's the at position. That's 31. And then we want to
extract the data that's one beyond the at up to but
not including the space. And that is the variable that
we're going to print out host. And so we extract this
bit of information and out comes the
host– quite nice, OK? We also saw another technique. And by the way, all
these techniques are OK. All these techniques are fine. Another technique we saw once
we sort of played the split and lists was what I
call the double split version of this where
the first thing we do is we split that line. The first thing we do
is we split the line. And then we know– and blanks–
that the second thing, which is the sub 1, word sub 1,
is the entire email address. And then this is
the double split. We take the email address and
we split it by an at sign. And then we get a list of the
pieces of the email address– the email name and
the email host– and then we grab
the sub 1 of that. And then we have the host
so that's the double split way of doing this, right? Now, in this, we still
haven't done the from yet. But it is the double
split way to do this. So if we think
about how we would do this in a regular
expression, we're going to say look
through the string. Find all– we're going
to– here's the find all. And the reg
expression exploded up says, look through
the string for an and. Do, do, do, do, got an and. Then, oh, start
extracting and extracting. And then this is another
form of the sync– this is one character. It's a single character. Match any non blank character
and zero or more of them, OK? So find an at sign. Start extracting and extracting. Match this is one character. That is a set of
possible matches. And that's some character. This means not– not a blank. That's a blank right there. That's a plane
character right there– not a blank as many
times as you want. You might want to
turn that into a plus to guarantee at least one. That might be better done
as a plus right there. So this would probably
make more sense as a plus to say I want at
least– after the at sign, I want at least one
non blank character. And the parentheses simply
say I don't want the at sign. So the at sign– I really want
those non blank characters after the at sign. So that's what I
want to extract. So it's like, go
find the at sign. OK, great, found the at sign. Start extracting. Look for non blank
characters and extracting. So pull that part out
and put it right there. Now, an even cooler version
of this that you probably kind of imagined right away
is we say, you know what? I would like this
first character to– the first part
of the line to be from with a blank followed
by any number of characters followed by an at sign. So the at sign is real. Then start extracting, then any
number of non blank characters and extracting. So this is like eight
or nine lines of Python all rolled into one thing, OK? so start at the
beginning of the line. Look for string
from with a space. Then skip a bunch of characters
looking for an at sign. Skip characters until
you encounter an at sign. Then start extracting. Match any non blank– a
single non blank character. So this is kind of like one
non blank character, one non blank character. But once you suffix
it with the asterisk, that changes it to be
many non blank characters. And then stop extracting, OK? So it's like, find from
followed by a space– great. That's the first part. Now throw away until
you find an at sign. Then start extracting. Keep going with non
blank characters until you hit the
first blank characters and pull that part out. Now, the result is we
get the exact same data. But with this added
to it, we're much more narrow in the kind of things
that we're looking for. And if we get noisy data that
like– say something like, you know, meet at Joe's, right? We don't want that. That won't match, right? We want that to be like a false. And that allows us
to sort of really fine tune our matching
and extracting. And this is just the beginning. They're very, very powerful. So the last thing
that I will show you is sort of a program
that is kind of like one of the programs that we
did in a previous section. Except now, we're going to use
regular expressions to do it. So if you remember,
we had this thing where we're doing spam
confidence where we're looking for lines and pulling
this number out and then calculating you the average
or the maximum or whatever. And so here is a– we import
the regular expression library. We open the file. We're going to do
this with appending to a list– we'll put
the numbers in a list rather than doing the
calculational loop. We strip the data. Now, here's the
key thing, right? We're going to have a
regular expression that says, look for the
first character being x followed by a
dash followed by all this. All this exactly has to match
literally followed by a colon. And then there's a space. And then we begin extracting. And we're looking for the
digits 0 through 9 or a dot. And we're looking
for one or more. And then we end extracting. So that's– the parentheses are
telling us what to pull out. So that just means
that we're going to pull out those numbers, all
the digits and the numbers, until we get something– I mean,
all the digits and the period and we'll get something other
than a digit and a period. And then we'll be done, OK? And so this is going to pull
those numbers out and give us back a list. Now, the thing
about it is we have to realize that sometimes
this is not going to match. Because we're sending
every line– not just the ones that start with x. We're sending every
line through this. And so we need to know
when we didn't get a match. And the way we know we didn't
get a match is if the list the number of items in the
list that we got back is zero, then we're going to continue. So this is kind of
our if we're searching for the needle in the haystack. But then once we find
what we're looking for, the actual number that
we're interested in is already sitting here
in stuff sub 0, OK? And then we convert to a float. We append it. And then when the
loop is all done, we print out the maximum, OK? And so this is sort of
encoding a number of things and ending up with a very
solid and safe matching. So we're really–
it's hard for this to find a line that's wrong. And you could even
improve this a little bit to make it even a little
tighter where it would go find a number like 0.999. You could say, oh, it's–
all the numbers are 0 dot– so you could make this a little
more so it would even skip things that– you can make it
so it looks exactly the way you want to look. So I emphasize that this is
kind of a weird language. And you need some kind of thing. We talked about all these. We have the beginning of a line. We have the end of the line
matching any character, matching space
characters, matching non-whitespace characters. Star is a modifier that
says zero or more times. Star question mark is a
modifier that says zero or more times non greedy. Plus is one or more times. Plus question mark is one
or more times non greedy. When you have bracket
syntax, it's a set. It's a single character
that's in the listed set. So that's lowercase vowels. You can also have the first–
if the first character of this is a caret, that flips it. So that means everything
except capital X, capital Y, capital
Z. So it's everything that's not in the set capital
X, capital Y, capital Z. And then you can also put
dashes in to represent ranges. Bracket a through z and 0
through 9 in lowercase letters and digits will match. But again, this is
a single character. Now, you can put a plus
or a star after these guys to make them happen
more than one time. And you can even
put them in twice. So if I wanted a two digit
number, I could say 0-9, 0-9. Oops, this is one character. This is one character and
this is the possible things. So that's, you know, 000 0
would match, 10 would match, 99 would match, et cetera. And then the parentheses
are the things that if you are in the middle
of a big long matching string and you don't want to
extract the whole thing, you can limit the things you're
extracting to the stuff that's just in there. With all these characters
that have all this meaning, we have to have a way to
match those characters. So dollar sign is
the end of a line. But what if we're looking for
something that actually has a dollar sign in the string? And that's what the
backslash is for. So if you put the
backslash in front of a otherwise
meaningful character, it becomes the actual character. So this is saying
match a dollar sign. Those two character say
match a dollar sign. And then this says one character
that's 0 through 9 or a dot. And then we put
the plus modifier to say at least
one or more times. And so that sort of is
a greedy, of course. So that will get us
this and extract it, including the dollar sign. So the escape character
is the backslash. OK, so there we are. Now we're done. So this is a little bit cryptic. It's kind of a puzzle. It's kind of fun and
it's extremely powerful. And you don't have to know it. You don't have to learn it. But if you do,
you'll find that it's very useful as we sort
of dig through data and are trying to write
things that are pretty quick. And the thing I like
about regular expressions is that they tend to be,
if you write them well, they tend to be less
sensitive to bad data. They tend to ignore data there. You can put more detail. I exactly want this. Or if you're writing
find and extract, you're making a lot of
assumptions about the data– that it's clean and you're not
going to miss hit on something. So OK, well, good luck in your
use of regular expressions and we'll see you later.

29 Comments

  1. Dimitrios Desmos said:

    you are a very good teacher

    May 22, 2019
    Reply
  2. Loop loop said:

    great video

    what is . ?

    May 22, 2019
    Reply
  3. Kostas Nikolouts said:

    I understand a lot.Thank you sir.

    May 22, 2019
    Reply
  4. John Morrison said:

    Also useful: expr? means the regex appears once or not at all.

    May 22, 2019
    Reply
  5. Guilherme said:

    God bless you!

    May 22, 2019
    Reply
  6. Minh Chiến Hà said:

    Can we replace [^ ] with [S] ?

    May 22, 2019
    Reply
  7. Rafael Gonzalez said:

    Thank you so much for making these videos! This one finally made sense to me after viewing three times!!!

    RegEx is a very complex idea for me, but your explanations made a big difference in helping me to learn it better, after the frustration of viewing 3-4 other videos on the same subject without much luck!

    Thanks again for all your work!

    Rafael G.

    May 22, 2019
    Reply
  8. Abdelkrim Bari said:

    Well explained. I have never seen someone explain this difficult topic. Well done. Thanks for sharing your experience.

    May 22, 2019
    Reply
  9. Biff Bifford said:

    This is the best Python tutorial geared towards extracting data — I have ever taken! Thank you for the time you put in this well developed tutorial.

    May 22, 2019
    Reply
  10. Miguel Sensacion said:

    I love Regex. I was using it with Perl. So cool !

    May 22, 2019
    Reply
  11. ali veli said:

    thank you for this great lecture.

    May 22, 2019
    Reply
  12. Garrett Rodrigues said:

    you could simplify even further with something like this.
    pat = re.compile(r'^X-DSPAM-CONFIDENCE: (.d+)', re.I | re.M)

    print max(map(float, re.findall(pat, hand.read())))

    the re.M flag allows you read through multiple lines all at once (so no more for loop) and the d matches all digits, just like [0-9]

    Great Video. Thanks

    May 22, 2019
    Reply
  13. Eric MacLeod said:

    This guy is so cool.

    May 22, 2019
    Reply
  14. Rud Dog said:

    This was Python 2.x or 3?
    print 'Maximum:',max(numlist)
    Generates an error:
    Message File Name Line Position
    Traceback
    <module> C:UsersmeDocumentsPYTHON_TEST_FOLDERfind.py 23
    ValueError: max() arg is an empty sequence

    May 22, 2019
    Reply
  15. Shruthi Reddy said:

    UofM, umsi student here, thanks for these videos 🙂

    May 22, 2019
    Reply
  16. Hammad said:

    you are actually GREAT 🙂

    May 22, 2019
    Reply
  17. Alex Vass said:

    "I'm DOWN with reg. ex.!!!" quote of the week!!! awesome

    May 22, 2019
    Reply
  18. Marcus Wiggins said:

    Thanks Dr. Chuck. Here is an example I found awhile back that would be a good practice session for students: https://developers.google.com/edu/python/exercises/baby-names

    May 22, 2019
    Reply
  19. Constantin Sandu said:

    I've successfully completed the Python for Informatics course on Coursera. You are an awesome teacher! Stay awesome and keep up the good work!

    May 22, 2019
    Reply
  20. Ariel Mendez Valentin said:

    Thank you Dr Chuck. I'm one of your students in Coursera (Python for Informatics). Now that we completed chapter 10 I will keep going with your videos in YouTube. I started other basic Python courses but your course is the first one I actually completed. Now I feel confident to go deeper into Python. Thanks for your talent and dedication to education.

    May 22, 2019
    Reply
  21. Sanil Pandit said:

    Don't be greedy. . Python lessons and Life lessons in the same video 🙂

    May 22, 2019
    Reply
  22. billel belaidi said:

    thank you very much, i really appreciate your course

    May 22, 2019
    Reply
  23. Lynne Hand said:

    Thank you very much.  It will take me a while to get it all sorted in my head, but that's my head's fault, not yours.  😀

    May 22, 2019
    Reply
  24. sanshinron said:

    If you can match b preceded by a just by using a(b), what's the purpose of positive lookbehind in regexp? I've used regexp before I've started to learn to program and always had to use (?<=a)b. which is positive lookbehind. What's the difference?

    May 22, 2019
    Reply
  25. leootp22 said:

    This is the most straight forward and easy to understand tutorial I have watched on regular expression to date. 10 minutes in and I went from having no clue what was going on to a great start at being able to at least imagine my own regexs. My hat goes off to you sir. Thank you.

    May 22, 2019
    Reply
  26. Ben Straub said:

    Great class!  Lectures are scaffold quite well and the exercises build on each other.  Just wish there were more problems to practice with video answers!!  I took the edx class for Python and it was way over my head…barely made it through.  I wish I had done this class first before the edx class!!  

    May 22, 2019
    Reply
  27. Les Carbonaro said:

    A not-so-straighforward topic wonderfully explained and brought down to earth by a consummate teacher. Been using regexp for a while, but have not come across such a lucid primer in a while. A great introduction.

    May 22, 2019
    Reply
  28. Alyn Evans said:

    Dr. Chuck I love your classes. As a Computer Security student in the UK I find your lectures extremely helpful. I took your Internet History, Technology, and Security class last summer and really enjoyed it. Thank you very much.

    May 22, 2019
    Reply
  29. Chuck Severance said:

    I am drinking coffee in a University of Michigan coffee cup.   SOMe videos I drink San Pellegrino Lemon or Orange.

    May 22, 2019
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *