Regular Expressions in Python || Python Tutorial || Learn Python Programming

  Рет қаралды 77,792

Socratica

Socratica

Күн бұрын

𝙎𝙩𝙖𝙮 𝙞𝙣 𝙩𝙝𝙚 𝙡𝙤𝙤𝙥 𝙄𝙉𝙁𝙄𝙉𝙄𝙏𝙀𝙇𝙔: snu.socratica.com/python
Regular Expressions (regex for short) is a way to search for patterns in strings. Python provides the re module to assist you in your efforts to search through strings. Maybe you want to find names in a database that satisfy certain conditions. But before you charge right in and start throwing regular expressions around, you need to learn the correct syntax.
In this video, you’ll learn how to compose regular expressions using such cryptic symbols as the caret (^), dollar sign ($), various backslashes (\d, \s, \w), and more. And just wait ‘til you see what happens when you start combining them into a powerful combo search expression.
We also introduce such concepts as quantifiers so you can see how many times you get a match. Match, that’s another handy function, along with fullmatch. You’ll learn how useful it can be to create groups to name certain parts of a regex. We could go on, but it makes more sense for you to watch the video and take notes. Then share it with a friend and have them take notes. Then you can compare your notes and see if you are in agreement.
We were able to bring you this video thanks to our generous Kickstarter backers! Find their names hidden (okay, not very hidden) in the video!
Find our programming playlists here:
Python: bit.ly/PythonSocratica
SQL: bit.ly/SQL_Socratica
Subscribe to Socratica + bell for notifications:
bit.ly/SocraticaSubscribe
⧓⧓⧓⧓⧓
We recommend:
How to Be a Great Student
ebook: amzn.to/2Lh3XSP
Paperback: amzn.to/3t5jeH3
Kindle Unlimited (read free): amzn.to/3atr8TJ
Python Cookbook, 3rd edition
amzn.to/3jprjX2
The Mythical Man Month - Essays on Software Engineering & Project Management
amzn.to/3hPn8Dd
⧓⧓⧓⧓⧓
Join this channel to get access to perks:
/ @socratica
Support Socratica on Patreon:
/ socratica
Python instructor: Ulka Simone Mohanty (@ulkam on Twitter)
Written & Produced by Michael Harrison
Edited by Megi Shuke and Michael Harrison
#Python #RegularExpressions #regex

Пікірлер: 158
@HarshitDaftary
@HarshitDaftary Жыл бұрын
Great to see python videos again 😊
@matthewwithum8372
@matthewwithum8372 Жыл бұрын
💯
@5cyndi
@5cyndi Жыл бұрын
I know right? 💜 I love the straightforward but humorous presentation.
@LandOfSigh
@LandOfSigh Жыл бұрын
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.
@patricksweeney6334
@patricksweeney6334 Жыл бұрын
I absolutely love Ulka's ability to deliver the dry sense of humor that permeates these videos. "To use regular expressions with python, import the 're' module. After hours of research, we were unable to find what 're' stands for."
@crownstupid
@crownstupid Жыл бұрын
something happens, and then they profit
@fredsmith6324
@fredsmith6324 Жыл бұрын
uhuh uhuh uhuh...
@Allen-by6ci
@Allen-by6ci Жыл бұрын
Ulka has perfected her character. More of her teaching everything. She's awesome
@massimo6767
@massimo6767 Жыл бұрын
Hi! I was a first year student when i used to watch your python tutorials. Now i am a full-time Data Eng. and seeing your videos again makes me kinda nostalgic (in a positive way). Thanks so much for your work, your videos helped me a lot during my first steps ❤
@Socratica
@Socratica Жыл бұрын
We love hearing about where your journey is taking you! Thanks for including us. 💜🦉
@EternalVoice11
@EternalVoice11 Жыл бұрын
Thank you Socrotica for these beautiful video tutorials
@nonominox
@nonominox Жыл бұрын
Perfect timing, we're just starting with re in our Python class!
@linghung9797
@linghung9797 9 ай бұрын
How is it going? I’m starting mine this week
@Socratica
@Socratica Жыл бұрын
𝙎𝙩𝙖𝙮 𝙞𝙣 𝙩𝙝𝙚 𝙡𝙤𝙤𝙥 𝙄𝙉𝙁𝙄𝙉𝙄𝙏𝙀𝙇𝙔: snu.socratica.com/python Quick Note: In regular expressions, a dot . matches ANY character. So our URL regex, https?://w{3}.\w+ etc works, but could be greatly improved if we replace the . pattern with \. The \. matches only the period.
@HexenzirkelZuluhed
@HexenzirkelZuluhed Жыл бұрын
Great video. Note however that in the last examples with the URLs, you are using '.' to look for a literal dot in the URL. A single dot in a pattern matches any character. If you want to look for a literal dot, you need to use '\.'. Also, Python supports verbose regular expressions, that allow comments inside the code.
@alexrubio9507
@alexrubio9507 9 ай бұрын
very good observation there
@jagadishgospat2548
@jagadishgospat2548 Жыл бұрын
I didn't expect it to be this easy to understand, thanks guys.
@davidawakim5473
@davidawakim5473 Жыл бұрын
Love that Socratica is back! Y'all make the best educational videos I've seen in a long time, just binged the abstract algebra playlist and now hoping into more learning! Thank you!!
@aiforyounow
@aiforyounow Жыл бұрын
Forever my favorite channel
@martinus9755
@martinus9755 Жыл бұрын
Great to see another one of these videos. They're clear, concise and the format is really fun.
@sarundayo
@sarundayo Жыл бұрын
Glad these series is still alive and well :DD
@bassbacke
@bassbacke Жыл бұрын
I thought I had some idea about regular expressions but now I know there's so much more to the re module. Thanks for inspiring us to dive deeper into the re module.
@MrPioneer7
@MrPioneer7 Жыл бұрын
Welcome back! Really happy to see your long videos again since you are the best teacher I've ever had
@5cyndi
@5cyndi Жыл бұрын
I love the dry wit of these Python tutorials 💜 I’ve been enjoying them for years and glad to see this new one! It’s so relevant. One can never have too many regexes. Well… maybe. But with this great presentation I am refreshing my skills and getting a chuckle at the same time. Cheers!
@EuphoricRaccoon
@EuphoricRaccoon Жыл бұрын
Seeing an upload of a Python tutorial with Ulka from Socratica once again after all this time made me incredibly happy. Seriously, all of these are a bloody gem
@gamorales
@gamorales Жыл бұрын
RegEx is one of the most beautiful things that exists. Python make RegEx really easy and simple to use. 😍
@BrianStDenis-pj1tq
@BrianStDenis-pj1tq Жыл бұрын
I love Socratica so much. The writing, presentation and subject matter are awesome.
@brunosantos3672
@brunosantos3672 Жыл бұрын
I'm happy to see a new Python video here!
@ehouston3
@ehouston3 Жыл бұрын
❤Thank you for creating more Python videos! Theses are THE BEST! You ladies are awesome, thanks for making knowledge accessible.
@hellionaires_sniping
@hellionaires_sniping Жыл бұрын
By far the best channel i know for learning python. Thanks for everything!!! Unfortunately i wasted a lot of time watching confusing video´s from other python developers.
@dewaynescott5114
@dewaynescott5114 Жыл бұрын
These videos rock. Have been leveraging them to learn Python. Thank you.
@chrisj21b
@chrisj21b Жыл бұрын
Great video, we need more of this!
@JANSENM9
@JANSENM9 Жыл бұрын
This is the reason I am a Socratica patreon. Thank you - there will never be too many of these!
@Socratica
@Socratica Жыл бұрын
Amazing. Thank you for helping us make these videos possible! 💜🦉
@shivamjaiswal5825
@shivamjaiswal5825 Жыл бұрын
Love Python videos from Socratica
@ydydydyd146
@ydydydyd146 Жыл бұрын
I really liked this video! It taught me everything I needed to know quickly and it was incredibly funny. You've earned my sub!
@user-dc9od8tn2r
@user-dc9od8tn2r 5 ай бұрын
Great videos ever seen ,Your are making the videos as more understanding the concepts .This is best tutorials in youtube everseen .Thanks for the tutorial and do more .
@NikitaNair
@NikitaNair 2 ай бұрын
Such an amazing video... Very easily explained and effective for learning
@pthube
@pthube Жыл бұрын
It is great to see you back..
@peter8261
@peter8261 7 ай бұрын
Her videos are like a Red Alert cinematic. I absolutely love them.
@SuperYtc1
@SuperYtc1 Жыл бұрын
I'm glad to see this series back. I said only this week in a video that I was sad they were discontinued. I hope you do more.
@SuperYtc1
@SuperYtc1 Жыл бұрын
Also would be good if you did some JavaScript in this style.
@WendimuSitotaw
@WendimuSitotaw Жыл бұрын
Love the python videos here at Socratica!
@angladephil
@angladephil Жыл бұрын
Nice to see you again !
@BrianStDenis-pj1tq
@BrianStDenis-pj1tq Жыл бұрын
Regular expressions go deep (really deep) - as in they are complicated and nuanced. This is an overview. The "corrections" explained in the comments are correct but maybe more useful for the next video on regex. I was going to suggest a video on regex module vs re... but that isn't a "learning" video, its an "advanced use case" video. Thanks Socratica!
@d0m2288
@d0m2288 20 күн бұрын
Awesome resource, as usual. I'm debugging an API and traced the issue back to some bad regular expression in one of the controllers.
@waltertross3581
@waltertross3581 Жыл бұрын
I'm glad you correctly pronounced regex (not like rejex) , and used the correct plural of index (indices). It took me a bit, though, to realize you were ironical about being unable to find the meaning of re.
@shinrafahell
@shinrafahell Жыл бұрын
Awesome tutorial, I love the way you teach.
@jimparsons6803
@jimparsons6803 Жыл бұрын
Thanks. Love these videos. Always a treat!
@amit12000
@amit12000 Жыл бұрын
Great video on regex and nice see new video after long time
@rantalbott6963
@rantalbott6963 Жыл бұрын
Add me to the people praising the "performance" (deadpan delivery and subtle humor) that makes these videos engaging and even entertaining. But I especially want to praise the basic design of splitting them into narrow topics and going into just the right depth. I've learned over a dozen languages over the last 50+ years, so what I'm looking for as I learn Python is not the "This is a bit. This is a byte. This is a loop" basics I learned decades ago. What I need is is answers like "How are lists different from C arrays?" and "How is regex matching different from Awk or Perl?". Last week I needed to do some input validation, and regexes were the right tool. A few minutes with this video showed me the Python way to do it without needing to wade through a lot of non-regex material. You're doing great. Thanks.
@markocska94
@markocska94 Жыл бұрын
I am so happy to see my favourite AI tutor back ❤
@klamentyne5991
@klamentyne5991 Жыл бұрын
Yay...she's back! xx
@yonaguska2050
@yonaguska2050 Жыл бұрын
I’ve missed her videos, she’s very entertaining.
@SatyaDurgapavaniGanta
@SatyaDurgapavaniGanta 3 ай бұрын
Finally I found the best video in KZbin
@zeitgenosse
@zeitgenosse Жыл бұрын
12:01 This regex will also match https followed by colon, followed by two forward slashes, followed by wwwsocraticaorg. The first dot would match the s, the backslash w+ would match ocratic and the last dot would match the a. To circumvent this, you need to escape the dot with a backslash.
@foustcor
@foustcor Жыл бұрын
Yay! Python's back!
@volbla
@volbla Жыл бұрын
One sequence i find handy is \h. It matches whitespaces, just like \s, but \s includes newline characters whereas \h doesn't. Usually when i search through text i want to keep to one line at a time. edit: Actually disregard that. Apparently that sequence is not in python's regex module :(
@nwoDekaTsyawlA
@nwoDekaTsyawlA Жыл бұрын
For some reason, my brain always forgets which of ^ and $ is the correct one to use in each case. Now I will always remember the ^farmer$.
@soufianta8374
@soufianta8374 4 ай бұрын
After months of research, I’m still unable to find what “re” stands for !! Love your videos !! Keep going
@thomas_m3092
@thomas_m3092 Жыл бұрын
I love your videos. Straight to the point, not like humans who waste a lot of time. Could you make some videos about GUI programming in Python?
@flarone
@flarone Жыл бұрын
This series is great.
@benatakaan613
@benatakaan613 Жыл бұрын
❤❤❤ More Python videos please!
@pippobraco8501
@pippobraco8501 Жыл бұрын
you're the best teacher
@freckhard
@freckhard Жыл бұрын
Hey there great video and finally some python again! I have an annotation at 12:12 to make: while the dot technically matches the dot in regular expression it stands for "any character at all" (including the dot 🙂). If you really need a dot (and not a hyphen or anything else) we would need to escape that as well with \. 👏 Happy Holidays Socratica!
@Socratica
@Socratica Жыл бұрын
Excellent point! We should have spent some time talking about the . pattern since it's so common. We'll pin a comment to make sure people understand the difference between . \.
@Flashxyz123
@Flashxyz123 11 ай бұрын
@@Socratica you never pinned this guys comment
@anesumukanya8811
@anesumukanya8811 Жыл бұрын
love ur work Ulka you are a star. Please do a video to demystify the use of the super() function!!!
@chefboyrdee1
@chefboyrdee1 Жыл бұрын
I needed this ! thank you
@pile333
@pile333 Жыл бұрын
Interesting! 👏
@angeloj.willems4362
@angeloj.willems4362 Жыл бұрын
Welcome back. We missed you! To save time and oxygen,... Classic! Something happens,... and then they profit. Hilarious!
@IIAyogu
@IIAyogu Жыл бұрын
A great content as always!
@oliver2671
@oliver2671 Жыл бұрын
Q: ChatGPT, please extract two consecutive vowels by using regex in python from following string: "Francois". A:.... Simple code problems do not need to be understood anymore, great!
@ithinkthereforeitalk935
@ithinkthereforeitalk935 Жыл бұрын
Exactly my thoughts. The revolution's coming but not too many people in the comment section are aware of this😉
@cuszco
@cuszco Жыл бұрын
I don't think "do not need to be understood anymore" is the right approach to this time saving marvel, though.
@oliver2671
@oliver2671 Жыл бұрын
@@cuszco Take it with a slight hint of sarcasm
@cuszco
@cuszco Жыл бұрын
@@oliver2671 That's actually a good idea. Thanks :D
@dieterweik6858
@dieterweik6858 Жыл бұрын
Who knows. Perhaps "Hand-coded" will become a thing. Just like "Hand-Made". Then again... maybe not.
@dwla16
@dwla16 Жыл бұрын
You turn the lesson into fun activity I love you for that❤ very unique way of teaching do you have any Java course
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
Here’s a handy one: “\b” for matching word boundaries. For example, using “\bi\b” to search through code for the variable “i” without matching parts of every single word containing the letter “i”.
@JC-ds1jh
@JC-ds1jh Жыл бұрын
Thank you I love your videos. I use them in my cyber security class to help my students with Python
@Socratica
@Socratica Жыл бұрын
We're so thrilled you're sharing our videos with your students. Thank you for letting us know!
@adithyays731
@adithyays731 4 ай бұрын
omg ur sense of humour is awesome
@iceiceisaac
@iceiceisaac Жыл бұрын
Love this channel
@lack76
@lack76 Жыл бұрын
Man I have spent quite a bit of time on regex, but as soon as I turn away from it for 5 seconds the knowledge floats away.
@NipkowDisk
@NipkowDisk Жыл бұрын
I think regular expressions are like oysters: you either love them or hate them. Personally, I love them as they really helped me to extract data from one file format and convert it into another for usage in a land surveying statistical analysis program :)
@nonominox
@nonominox Жыл бұрын
@Socratica which editor/theme do you use?
@abhideepsingh4484
@abhideepsingh4484 Жыл бұрын
after a long time!
@bobert13581
@bobert13581 7 ай бұрын
thanks for saving some of my oxygen with this efficient learnings
@dhamodharang7665
@dhamodharang7665 7 ай бұрын
Good to understand 😊
@XxKingfisherxX
@XxKingfisherxX Жыл бұрын
i think you meant letters when you are saying words!! you contents are awesome
@hasanyousef492
@hasanyousef492 Жыл бұрын
great video and presentation, what is the software you used to make such great presentation?
@scottbiggs8894
@scottbiggs8894 7 ай бұрын
I deeply applaud this video, thank you! But could you update this for python 3? A host of regex no longer functions as specified in this video.
@DENIESCAT
@DENIESCAT Жыл бұрын
Nice tutorial and nice video
@OP-do7rt
@OP-do7rt Жыл бұрын
pls teach full python we love you
@jpt13913
@jpt13913 Жыл бұрын
Enjoy examples They help Make it clear
@kwrifles
@kwrifles Жыл бұрын
Regex is very powerful but I've always found it easy but confusing
@finnbin1
@finnbin1 Жыл бұрын
WOW ...me at 5.32.... how cool is that???? cool video...
@muhammedfahimkpfahim8606
@muhammedfahimkpfahim8606 10 ай бұрын
good explantion thankyou
@StevenHancz
@StevenHancz Жыл бұрын
Correction @6:55 the regex is looking for strings that contain 'C' followed by word characters not string shat start with 'C' character. The regex needs the ^ prefix to make it search for sting starting with 'C'.
@Socratica
@Socratica Жыл бұрын
We were actually using this regex to look for any sequence of characters that starts with C, not strings that start with C themselves. Here's a case where some emphasis would have been a good idea, especially since so many of our examples used the ^ pattern.
@kirbymarchbarcena
@kirbymarchbarcena Жыл бұрын
Her expressions are so priceless
@victorcercasin
@victorcercasin 11 ай бұрын
"They start with carrots, something happens, and then they profit". That shit in 2x speed is hilarious
@RichPenn
@RichPenn Жыл бұрын
Well done as always, glad to see a new one. Richard K5ANR
@maximillianquaife-larsen3799
@maximillianquaife-larsen3799 3 ай бұрын
Thank you
@fdama
@fdama Жыл бұрын
7:29 How did the regex match "HappyCodingRobot"? It starts with H not C.
@GrypV
@GrypV Жыл бұрын
Thanks!
@Socratica
@Socratica Жыл бұрын
Thank you so much for your kind support!! 💜🦉
@XxKingfisherxX
@XxKingfisherxX Жыл бұрын
what does "?=.*" mean in regex? Expecting detail lesson.
@kyoujinko
@kyoujinko 3 ай бұрын
;0Thank you, I just wanted to know what REGEX was. Other videos were getting very complicated into the process of it, and all I wanted was to know what it was
@Flashxyz123
@Flashxyz123 11 ай бұрын
doesnt the RE module stand for regular expretions?
@danycordero5308
@danycordero5308 Ай бұрын
Hi Socratica, Please be informed that the examples using char (code 710)" ^ " shown in this video do not match with the objetive ?? can you explain the reason? , for example the expression /^\w{7}$ / does not find any character.
@calebthiem3150
@calebthiem3150 Жыл бұрын
Thanks
@Socratica
@Socratica Жыл бұрын
Goodness, thank you so much for your support! 💜🦉
@SpeaksYourWord
@SpeaksYourWord 6 ай бұрын
re stands for regular expressions?
@jonnmostovoy2406
@jonnmostovoy2406 Жыл бұрын
Don't use regular expressions. Use parser combinators. Thank me later. Parsec is a parser combinator library for Python. User gdevanla has a nice blogpost about it.
@Lilina3456
@Lilina3456 9 ай бұрын
RE stands for Regular Expressions 5:00
@wonderingwoman769
@wonderingwoman769 2 ай бұрын
"Humans spend much of their time searching for meaning, Coders spend much of their time searching through strings" is so true 🤣🤣🤣🤣
@timarmstrong8765
@timarmstrong8765 Жыл бұрын
Wait is this new series for Python?
@xReeco
@xReeco Жыл бұрын
best
@akshaybaura
@akshaybaura Жыл бұрын
re probably just stands for Regular Expressions. :)
Python Pickle Module - Socratica #Shorts
0:38
Socratica
Рет қаралды 34 М.
100❤️
00:20
Nonomen ノノメン
Рет қаралды 56 МЛН
Pray For Palestine 😢🇵🇸|
00:23
Ak Ultra
Рет қаралды 35 МЛН
Regular Expressions - Computerphile
17:19
Computerphile
Рет қаралды 238 М.
Learn Regular Expressions In 20 Minutes
20:52
Web Dev Simplified
Рет қаралды 1,2 МЛН
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,5 МЛН
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1 МЛН
Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text
37:55
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,4 МЛН