Тёмный

Complete Regular Expressions Tutorial! (with exercises for practice) 

Keith Galli
Подписаться 222 тыс.
Просмотров 19 тыс.
50% 1

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!
RU-vid - / @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.)

Опубликовано:

 

3 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 40   
@Fflaring
@Fflaring Год назад
Oh man, I waited this so long, thank you for this video!
@javaluvawithjeremystones6315
@javaluvawithjeremystones6315 2 месяца назад
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.
@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
@FunnyFunnyMoneyHoney
@FunnyFunnyMoneyHoney 11 месяцев назад
You are a really good teacher.
@johnnybegood948
@johnnybegood948 11 месяцев назад
You are the best! Thank you for this video props from brazil
@giacomobianchi3857
@giacomobianchi3857 Год назад
Finally I understood regex!!! Thank you
@KeithGalli
@KeithGalli Год назад
You're very welcome! Glad it was helpful.
@leonardoferreiracalazans9210
@leonardoferreiracalazans9210 5 месяцев назад
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
@Evan-e-cent
@Evan-e-cent 8 месяцев назад
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.
@shangtee1
@shangtee1 10 месяцев назад
Very useful!
@user-lg5jf1oq1d
@user-lg5jf1oq1d 4 месяца назад
37:54 you can use range eg. [1-31]
@shawnabirnbaum8658
@shawnabirnbaum8658 Год назад
I would love to see a video on syntax trees and X' theory!
@maxximumb
@maxximumb 10 месяцев назад
Ali sent me. Am so glad she did. You have some great videos.
@motlatsimoea5615
@motlatsimoea5615 Год назад
Yes!!!!!!! Favorite tutor about to tackle a subject I've beeeeeeeen wanting to learn! Can't fight fate! Let's go!!!!!!!!
@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 :)
@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
@rayedriasat8079
@rayedriasat8079 5 месяцев назад
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
@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 :)
@user-xj4cl9uu9p
@user-xj4cl9uu9p Год назад
Great video, Could you please prepare new video(tutorials) about ML?
@FUNNEAS
@FUNNEAS 9 месяцев назад
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
@ucphattruong4341
@ucphattruong4341 8 месяцев назад
Omg. Thanks to you, I could understand the regex. You're truly life saver
@KeithGalli
@KeithGalli 7 месяцев назад
Glad the video was helpful!!
@youturunnyng
@youturunnyng 5 дней назад
​@@KeithGalliRubén godoy islas
@youturunnyng
@youturunnyng 5 дней назад
Rubén godoy islas
@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
@MrBulatovich
@MrBulatovich Год назад
Так-то ничё! Просто и понятно.
@wahidali9145
@wahidali9145 10 месяцев назад
Hey keith, im looking for data science job. Can you help in that, any reference
@sebastianalvarez1537
@sebastianalvarez1537 Год назад
lets go
@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.
@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. ▶
@user-jj4dz2wt7i
@user-jj4dz2wt7i 10 месяцев назад
Hey Keith! Here from Ali's channel. I wanna see my name in sparkles aa
@dsinghr
@dsinghr 4 месяца назад
the password regex is not working for me!
@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+)
Далее
Regular Expressions - Computerphile
17:19
Просмотров 239 тыс.
🤘РОК или ПОП?💖
3:20:26
Просмотров 1,7 млн
Guess The Drawing! ✍️✨🧐 #shortsart
00:14
Просмотров 1,5 млн
5 Good Python Habits
17:35
Просмотров 406 тыс.
Solving real world data science tasks with Python Pandas!
1:26:07
Learn Regular Expressions In 20 Minutes
20:52
Просмотров 1,2 млн