No video

Complete Regular Expressions Tutorial! (with exercises for practice)

  Рет қаралды 20,279

Keith Galli

Keith Galli

Күн бұрын

Practice your Python Pandas data science skills with problems on StrataScratch!
stratascratch.com/?via=keith
In this video we go through all the fundamentals of using regular expressions (regexes) to match patterns in programming.
In this video we cover the following:
- Character Sets [a-zA-Z0-9]
- Quantifiers *, +, ?, {3,5}
- Metacharacters ^ . | $
- Character Classes \b \s \w \d
- Groups
- Lookahead & Lookbehind assertions
- and more!
There is a detailed timeline down below.
In a future video we will apply what we learn in this one to the Python programming language (re library) -- subscribe to not miss that!
Resources!
Source code & txt files: github.com/keithgalli/regular...
Practice exercise video: • Practice Regular Expre...
Cheat sheet: cheatography.com/davechild/ch...
Regex golf: alf.nu/RegexGolf
Javascript Info: javascript.info/regexp-lookah...
-------------------------
Follow me on social media!
Instagram | / keithgalli
Twitter | / keithgalli
TikTok | / keithgalli
-------------------------
If you are curious to learn how I make my tutorials, check out this video: • How to Make a High Qua...
Practice your Python Pandas data science skills with problems on StrataScratch!
stratascratch.com/?via=keith
Join the Python Army to get access to perks!
KZfaq - / @keithgalli
Patreon - / keithgalli
*I use affiliate links on the products that I recommend. I may earn a purchase commission or a referral bonus from the usage of these links.
-------------------------
Video timeline!
0:00 - Video overview & topics covered
1:43 - Basic regex syntax (building up an intuition)
4:23 - Character Sets Overview ([A-Za-z0-9])
5:57 - Quantifiers Guide (*, +, ?, {3,5})
9:30 - Guided Exercise: Find all words that don't use vowels
11:08 - Helpful cheat sheet to remember regex syntax in the real-world
12:47 - Matching words/patterns of a specific length ({3,5})
14:58 - OR operator overview
17:14 - Guided Exercise: Match valid sentences (starts with capital letter, ends with period)
21:18 - Character classes overview (\w, \b, \d, \s)
23:13 - Escaping Characters
25:02 - Practice Exercise #1: Write a regular expression to match meme text format
30:39 - Practice Exercise #2: Write a regular expression to match a specific date format
39:03 - Groups overview
50:16 - Lookahead & Lookbehind Assertions
1:00:18 - Practice Exercise #3: Detect if same word pops up multiple times in a sentence
1:06:04 - Practice Exercise #4: Password matching with rules
1:16:16 - Some final recommendations! (additional practice, chatgpt, etc.)

Пікірлер: 40
@Fflaring
@Fflaring Жыл бұрын
Oh man, I waited this so long, thank you for this video!
@stefanomedici5326
@stefanomedici5326 Жыл бұрын
Always super helpful! Thank you Keith :)
@ahmadshabaz2724
@ahmadshabaz2724 8 ай бұрын
nothing better than entire you tube . your work is awesome . its really helpful man . thanks a lots
@javaluvawithjeremystones6315
@javaluvawithjeremystones6315 3 ай бұрын
Really amazing video! Thanks for the great content! For the part where it was allowing you to not escape the period in the square brackets, it's not sublime, you don't need to escape characters inside square brackets, although it won't complain if you do escape them. The only exception I can currently think of is the ^ symbol and only if you put it at the beginning.
@Evan-e-cent
@Evan-e-cent 9 ай бұрын
Hi, I hope you don't mind if I comment on names for symbols: # is called 'pound' because on British keyboards it is the money symbol £ (try option#) ! is the exclamation point or mark that you referred to later < I call the less-than symbol or angle bracket in HTML > is the greater than symbol (it is bigger on the left side) * is an Asterisk which means star. Commonly called just 'star'. | is sometimes called a pipe or vertical bar THANKS FOR A GREAT VIDEO ! WATCHED FROM BEGINNING TO END and made a note of the PDF cheat sheet. Very useful.
@Pythagoras31415
@Pythagoras31415 Жыл бұрын
You are a really good teacher.
@leonardoferreiracalazans9210
@leonardoferreiracalazans9210 6 ай бұрын
Thank you for the video! In negative lookbehind, try to use \b before the pattern you want to match. It has worked for me!
@KeithGalli
@KeithGalli 5 ай бұрын
Thanks for the tip! Glad you enjoyed the video
@johnnybegood948
@johnnybegood948 Жыл бұрын
You are the best! Thank you for this video props from brazil
@rayedriasat8079
@rayedriasat8079 6 ай бұрын
at 38:52 I used [01][0-9][-./][0-3][0-9][-./]\d{4} here inside [ ] square brackets we don't need to escape the dot (.) it is just dot, if we had used dot outside of square brackets then we had to escape dot. Cuz dot outside [] means everything except newline
@user-lg5jf1oq1d
@user-lg5jf1oq1d 4 ай бұрын
37:54 you can use range eg. [1-31]
@shangtee1
@shangtee1 11 ай бұрын
Very useful!
@motlatsimoea5615
@motlatsimoea5615 Жыл бұрын
Yes!!!!!!! Favorite tutor about to tackle a subject I've beeeeeeeen wanting to learn! Can't fight fate! Let's go!!!!!!!!
@giacomobianchi3857
@giacomobianchi3857 Жыл бұрын
Finally I understood regex!!! Thank you
@KeithGalli
@KeithGalli Жыл бұрын
You're very welcome! Glad it was helpful.
@JumaleAbdi-tu3zh
@JumaleAbdi-tu3zh Жыл бұрын
Hey, Thank you for the amazing content. Please Would you mind covering about End to End Pytorch series from the Problem statement, Data Collection, Modeling, Deployment, and Testing
@shawnabirnbaum8658
@shawnabirnbaum8658 Жыл бұрын
I would love to see a video on syntax trees and X' theory!
@michaelpurtell6157
@michaelpurtell6157 Жыл бұрын
The legendary movie from Feb 1996 was Happy Gilmore! It surely contributed to the recent Kennedy Center honors for Adam Sandler. And a great video released on April 13, 2023 is the RegEx tutorial from Keith Galli, great job.
@KeithGalli
@KeithGalli Жыл бұрын
Correct, and haha thank you for the kind words! Glad you enjoyed :)
@maxximumb
@maxximumb 11 ай бұрын
Ali sent me. Am so glad she did. You have some great videos.
@user-xj4cl9uu9p
@user-xj4cl9uu9p Жыл бұрын
Great video, Could you please prepare new video(tutorials) about ML?
@anonviewerciv
@anonviewerciv Жыл бұрын
My body is regex. 🔎📃 10:50 Linguistically speaking, [y] can be a vowel, especially in words like "crypt". Pedantry of course, since it could just be added into the regex if needed. 🤓 36:40 Might not really be up to regex to do data validation. There are better tools for that. 🧰 In fact, integrating these into data workflows would be a good follow-up video for the future. ▶
@FUNNEAS
@FUNNEAS 10 ай бұрын
Hi Keith, excellent video on regex.... One of the best videos made ever on youtube on regex.....im glad i found your video.......Can you make video on finding specific word in a sentence ex (i want to cancel my service. Please cancel my hbo, i want to can sail please console my service, im interested in cancelling) multiple words like this and we want to match word only (cancel | can sail |console service) and ommit any other word like 'cancel hbo' 'cancel bill' ..... Any way can i reach out to you personally with sample. Thanks
@billsneddon
@billsneddon Жыл бұрын
not optimal but (0[1-9]|1[0-2]) would only match months 01-12
@KeithGalli
@KeithGalli Жыл бұрын
That's a smart solution! Didn't think of that, thanks for sharing :)
@DendrocnideMoroides
@DendrocnideMoroides Жыл бұрын
a period in a character class only matches a period, same for the other metacharacters like ? * +, the reason for this is there is no use to have a character match every character inside a character class, since for that you would not even need a character class, similar reasoning for the other metacharacters
@ucphattruong4341
@ucphattruong4341 9 ай бұрын
Omg. Thanks to you, I could understand the regex. You're truly life saver
@KeithGalli
@KeithGalli 7 ай бұрын
Glad the video was helpful!!
@youturunnyng
@youturunnyng Ай бұрын
​@@KeithGalliRubén godoy islas
@youturunnyng
@youturunnyng Ай бұрын
Rubén godoy islas
@wahidali9145
@wahidali9145 11 ай бұрын
Hey keith, im looking for data science job. Can you help in that, any reference
@sebastianalvarez1537
@sebastianalvarez1537 Жыл бұрын
lets go
@MrBulatovich
@MrBulatovich Жыл бұрын
Так-то ничё! Просто и понятно.
@dsinghr
@dsinghr 5 ай бұрын
the password regex is not working for me!
@sloughpacman
@sloughpacman Жыл бұрын
Happy Gilmore 😀
@KeithGalli
@KeithGalli Жыл бұрын
Haha you got it! 🤝
@sloughpacman
@sloughpacman Жыл бұрын
@@KeithGalli Good video Keith, and some good links too. Regex is a fun diversion from time to time, just like playing around with AWK and SED in shell scripts. If you ever get some time to explore hacking binary/executable files I would recommend it, you'll find it very satisfying and right up your street.
@user-jj4dz2wt7i
@user-jj4dz2wt7i 11 ай бұрын
Hey Keith! Here from Ali's channel. I wanna see my name in sparkles aa
@DendrocnideMoroides
@DendrocnideMoroides Жыл бұрын
49:02 You could definitely get everything if you add an extra parenthesis around the thing you want to get in this case (([a-z][A-Z])+[a-z]?)@(\w+\.\w+)
Genetic Algorithms Explained By Example
11:52
Kie Codes
Рет қаралды 318 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 32 МЛН
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 100 МЛН
Web Scraping with Python - Beautiful Soup Crash Course
1:08:23
freeCodeCamp.org
Рет қаралды 1,5 МЛН
Regular Expressions - Computerphile
17:19
Computerphile
Рет қаралды 241 М.
Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text
37:55
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 285 М.
Learn Regular Expressions In 20 Minutes
20:52
Web Dev Simplified
Рет қаралды 1,2 МЛН
Regular Expressions (RegEx) Complete Tutorial.
2:56:16
nETSETOS
Рет қаралды 11 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 32 МЛН