Learn to Program 15 : Regular Expression Tutorial

preview_player
Показать описание


In this video I start teaching about Regular Expressions. Regular expressions allow you to locate and change strings in very powerful ways. The awesome thing about them is they work in almost exactly the same way in every programming language. We'll learn to match strings, return all matches, and use ., [ ], [^ ], compile, substitute, \d, \D, \w, \W, \s, \S, +, { }, and much more.

Thank you to Patreon supports like the following for helping me make this video

@kyleaisho
@thetwistedhat
vjFaLk
Рекомендации по теме
Комментарии
Автор

Hey, Derek! I just wanted to say how glad I am that you make these videos! Every time I have a problem in almost any language and I search for the answer, I always come up with your videos. You are a very good teacher that I am very thankful for. Thanks for making these videos and helping newbies like me! : )

SirBloopsALot
Автор

hats of to you for the awesome series. as the dude on youtube who always proposes stuff a basic ML tutorial with python would complement this series perfectly. Thanks for the effort

mareinstalator
Автор

Hi Derek! you are about to make my life so much easier!

olawalejimoh
Автор

Another, awesome learn to program. Great work Derek!

reaganmaxwell
Автор

Heart warming voice. Happy Weekend, Derek.

TheOldmankk
Автор

I got directed from "Python Programming". This is another good video. You are helping me greatly :D

P.S. One thing I noticed is that you should 'escape' the period in the format statement in email example.

straybits
Автор

What's the difference between these two syntaxes?

print("Matches: ", len(re.findall("a+", "a as ape bug")))
and
print("Matches: ", len(re.findall("a.", "a as ape bug")))

agnibhachakz
Автор

Thank you Derek. I know a little English but I am developing myself throught your videos:)

mangir
Автор

Great tutorials about regex. I'd like to thank you for making these wonderful tutorials about python and other languages. Your work is awesome!

sumantkanala
Автор

Hi Derek,

when i compile your find email code, with the string ".+-%_" not included, it runs exactly the same (will still find email addresses to be valid if they have those chars)

I had a strange issue w my code before trying yours

nickpatrol
Автор

I ended this series after the threading video as I got lost and now it turns out I may need regex in the bot I'm making. I'm back for me. Goodie!

BabyBallascore
Автор

Your work makes me aspire Derek. Your everyone's hero.

silhouettefalcon
Автор

Hi Derek. I would like to mention that the example that checking if a First name is valid by searching between 2 and 20 characters doesn't really work. Even if you have a string of more than 20 characters still search returns valid. I would really like to know if there is another way to make it work as it's really nice thing to be able to do. thanks.
By the way the same happens with the full name and the email problem + I think you have forgotten to add the "\" before the dot at the end of that command.

condafarti
Автор

sorry meant to put this comment on this module (15) :
Hi Derek, in your last exercise to check how many valid email addresses,
like the range {2, 3} you put after [a-zA] only work for the first
argument (ie 2) so it will force the string to have 2 characters but it
ignores the second argument (ie 3). so how would you enfore that after
the final "." you really have only 2 or 3 characters (.us or .com and
not something like .comedu ?
just FYI, I am using PyCharm on windows

themed
Автор

Thanks Derek for this really nice video.
I think the last regexp for email in not correct. To match the last . should you not use \.?

idefixable
Автор

Derek,
You're videos are great, and cover such a breadth of languages.
Would you consider creating a tutorial on R programming language? Even an hour video would be great!

tomlake
Автор

print("Matches :", len(re.findall("a", "a as ape bug")))
print("Matches :", re.findall("a+", "a as ape bug"))
for i in re.findall("a+", "a as ape bug"):
print(i)

the + doesn't do anything for me, it prints just "a"

aviadomeisi
Автор

Thank you so much for these videos! They are really helpful.

avrevapark
Автор

At 23:12, isn't it '\.' as just '.' matches any character?

vamsimohanramineedi
Автор

What if I set a regex to look for lets say 1-9, %, $, @ and want to print out how many matches (if all were found in there there should be the count of 4 matches)?

AMC-throwaway