Learn Regular Expressions In 20 Minutes
Having the ability to search through text, validate text, and replace text using an advanced set of rules is exactly what Regex is for. Unfortunately, people fail to ever truly learn Regex. In this video I will be teaching you everything you need to know about Regex. We will talk about what Regex is, what Regex flags are, how to do simple and complex matches, how to handle look aheads and look behinds, and much more. Then at the end of the video I will show you how to use Regex to validate and format a phone number in various different formats.
📚 Materials/References:
Regexr Website: regexr.com
🧠 Concepts Covered:
- What Regex is
- How to use Regex for simple matching
- How to match repeating patterns
- What Regex flags are
- Look aheads and look behinds
- Regex special characters
- Validation with Regex
- Find and replace with Regex
🌎 Find Me Here:
My Courses: courses.webdevsimplified.com
Patreon: / webdevsimplified
Twitter: / devsimplified
Discord: / discord
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
#Regex #WDS #RegularExpression
Пікірлер: 1 000
This is great stuff man. Sorry I didn't check out your channel sooner. A lot of people recommeded it in my last video..Subbed :)
@zulfequar_ali
4 жыл бұрын
Hi Brad 😊 You are my master. Your tutorials are really so easy to understand. Each of your videos has a lot of things to learn and quite easy to learn. The key is, listen carefully and code alog with Brad, you will become the master of whatever Brad is teaching.
@WebDevSimplified
4 жыл бұрын
Thank you so much! I checked out your video just a little bit ago and loved the list you created. There were so many good creators on there and hearing New Boston on the list brought back all my memories of first learning web development from his channel. I also want to give a huge thanks to your for your channel. I have learned a ton from you and your channel was one of my biggest inspirations for starting my own channel.
@mubarokibnu
4 жыл бұрын
Two of my best programming Tutor on KZread
@ahmadkhudai
4 жыл бұрын
Subbed just for this comment. Now I will actually start the video
@mykalimba
4 жыл бұрын
Whoa, Brad Traversy in the comments!?!??? In the words of Nicolas Cage, "That's high praise."
creating proper regex is pretty simple. step 1: open your preferred editor step 2: let a cat play on your keyboard
@dubletar7351
3 жыл бұрын
😂😂😂
@kathieblakeslee986
3 жыл бұрын
@@dubletar7351 So very true.
@ankitmishra_95
3 жыл бұрын
😂😂 correct
@SyedAli-kr6qw
2 жыл бұрын
And that's how RegEx was created.
1:05 what is regEx 1:50 introduction and flags 3:40 + match one or more 4:18 ? optional 4:48 * zero or more 5:16 . anything except a new line 5:50 \ to cancel anything after 6:18 \w for words 6:37 negative versions 6:56 {} to indicate a quatitiy 7:45 [] group and ranges 8:38 () own groups 9:13 how | works 9:53 combination of () | and {} 11:00 ^ beginning of new paragraph and multiline 12:00 $ end of statement until there the 90% of regular expresions 12:50 (?
@RaviKiranBachu
2 жыл бұрын
Thank you !!
@lararawf6100
2 жыл бұрын
God bless u
@hansgerber8654
2 жыл бұрын
Tyvm just a small fix: non capture groups would look like this (?: ...)
@grubybueno
2 жыл бұрын
@@hansgerber8654 thanks, fixed!
@Kofi07
Жыл бұрын
People like this>>>>>❤️
I have tried many different sites to fully understand regular expressions for input validation, and this video was by far the most helpful!
@serpenteve
3 жыл бұрын
Same with me bro.
@zaid696
2 жыл бұрын
@@serpenteve b'coz of lots of tried, u had already understood, here u furnished ur knowledge.
Learn regex in 20 minutes, forget in 10
@braindeveloperdimensional5579
4 жыл бұрын
Then you are an idiot for not taking notes.
@arnoldasdrapanauskis5924
4 жыл бұрын
@@braindeveloperdimensional5579 I like this comment. But why you need notes, when you have google xD ?
@braindeveloperdimensional5579
4 жыл бұрын
@@arnoldasdrapanauskis5924 oh really? And tell me you don't get distracted Everytime you open your phone.
@BlademanZX
4 жыл бұрын
@@braindeveloperdimensional5579 Have you heard of this newfangled thing called "joking"?
@arnoldasdrapanauskis5924
4 жыл бұрын
@@braindeveloperdimensional5579 Well, yes I do. Distractions everywhere. But i use PC when programming, not phone ;)
This is a really compact, concise video covering everything you need about regular expressions. I'm very experienced with regular expressions, but came here to get more info about look ahead and look behind, and you described those in a way that is much more meaningful than anything else I've run across online. Truly great work.
I'm so grateful for your JS videos. Sometimes i get stuck on documentations for over an hour without any understanding of the content, then I come here and everything seems so clear. Keep up the awesome job!
In my long experience, I find that everybody learns regex every time they use it. Even if you look at perfectly reasonable regex 3 weeks after writing it, it's alien script.
@lauris5275
2 жыл бұрын
This is so true. 2 months ago i learned regex a bit , but now i dont even know how to validate a phone number. I Copy pasted email validation somewhere and boom. Done. I think its more important to know what regex can do and knowing when to use it. Not actually how to write that code. Thats my opinion cause if ur not using it regularly then u will forget about it in 2 weeks.
@user-ky9qn4pg3w
2 жыл бұрын
that's why they call em regular expressions. cuz you need to be using them regularly to understand them.
@xizhecheng1139
2 ай бұрын
@@lauris5275 now imagine you are asked that in an interview while you state you are familiar with regex on your resume
Very concise tutorial. Covered many aspects of Regex and explained in easy to understand layman terms in a compact 20 minute session yet not omitting key details. Thank you very much for sharing your knowledge.
This is an excellent tutorial. It is a very clear explanation. I will ask all of my programming friends who shy away from regex to watch it. I've been using regex for decades, and I still have trouble with look-ahead and things like that. I always have to refresh my memory after I stop using it for awhile. After watching this video I feel like I understand the entire concept much better. Thank you very much.
This is the best Regex video I've ever watched. Bravo to you sir for breaking this down. Easily one of the most confusing aspects of programming in my opinion.
Really an unbeatable example of how to convey information. This guy is clearly intelligent and can plan and execute, good job and thanks for the video
Simply the best regex tutorial ever! Wish my teachers had explained it like this. Thank you!
@dedoyxp
2 жыл бұрын
your teacher can explain it like this... ...by play this video in class lol
@neganega564
Жыл бұрын
@@dedoyxp honestly they should just do that if they cant explain it better look for a video that does
Wow, thank you so much. I'm working on a really complex algorithm that needs to use regex, but I have had such a hard time understanding it until now!
Excellent! This was a perfect summary of regex which I really needed. Just used it in some Google Apps Scripts I'm writing and it has made a huge difference in my ability to pull specific links from XML code. No more depending on importXML function to find matches. I had learned this in college about 15 years ago but never applied it so this was a life saver. THANKS!!!
I compared your video with others. In 20 minutes, you explained the most important concepts clearly. Thank you, save our time and our life. You are a very smart tutor.
I'm amazed how calmly and thoroughly you're explaining everything... Great work, I managed to write the regex I needed, thank you!
Naming capture groups is more important than you think and is a good habit to get into early. In JavaScript you can reference these names as object keys which gives so much more clarity to your code.
Great info. Regex seems so daunting at first but once its broken down well like this, it becomes much easier to understand.
I've used RegEx for about 20 years now...used it in PERL, C++, VBA (Word), Bash, Python....even inside apps like Alteryx and Talend!! I've given so many impromptu classes to try and help folks understand the real power of RegEx. It is ridiculously powerful! Thank you for this vid...more information out there to help people is a good thing! Cheers!!
This was so well made. Easy to understand but very detailed. Thanks a lot!
Great info in a short amount of time, I was strugling with building complex regexes and this helped a lot!
I've been looking for a walkthrough like this for a long time thankyou
I watched this as a refresher and left learning a couple new things. Thank you!
Regex: 20 minutes to learn, a lifetime to master. 😂
@dzdeparsio4676
2 жыл бұрын
loool
@CryptoNerd91
2 жыл бұрын
@Chris Walker So true 😭😭😂
@chrisnandasaputra2708
2 жыл бұрын
ROFL
@RAJAT2372
2 жыл бұрын
No kidding!
@ClaysonShawn
2 жыл бұрын
That's actually really good to know that this takes time for everyone! I've been stressing out that I don't know this well enough.
Oh my gosh, this is fabulous!! Thank you so much. We're just starting to study regex in my web design course and I was so lost. I actually get it now. Amazing!
@yash1152
2 жыл бұрын
the videos on ur channel are nice and pleasing :) 👍👍
Very good and complete explanation of regular expressions. Most regex tutorials skip the very useful "look behind" and "look ahead" capabilities.
Thank you so much! I have been meaning to learn regex for years but all the weird characters looked so daunting I just kept putting it off. This video made it super easy and simple to understand! I have been having a lot of fun playing around with different regular expressions practicing them which I never thought I would be able to do. Thank you!
Regex is one of my weaknesses. Thanks for helping me understand it. Your tutorial is better than the documentation.
@kekohokko7213
3 жыл бұрын
Jeffrey Friedl's Mastering Regular Expressions is the de-facto user manual for regular expressions (and an impressively written book besides). Give that a try if you really want to understand RE and how they work.
@GregoryEsman
2 жыл бұрын
Honestly I've never found an easy to understand piece of coding documentation before
@sinnvoi
2 жыл бұрын
@@GregoryEsman same, i think that's why people are paying for courses etc.
This man staring right into my soul, that shit making me uncomfortable but at the same time I kind of like it
That is probably the best and most comprehensive regex video I found on KZread. Thanks mate!
I believe you must not be more than 24 years and the way you are teaching looks like you have more than 10 years of experience in field. very awesome and appreciated
Watched all your videos, love your teaching style, keep up with the good work!
@WebDevSimplified
4 жыл бұрын
Thank you!
You are just amazing! I love your way of teaching.
@WebDevSimplified
4 жыл бұрын
Thank you!
You are just a diamond on the web industry! Thanks for investing your time! Love you
You are crazy, in a good way. You are offering such great information for free. It helps me so, so much. Thanks for your work! My hat's off to you.
@braindeveloperdimensional5579
4 жыл бұрын
@ronald seawell Try saying that to colleges. They'll beat your ass.
@salvationprayerfellowship8899
4 жыл бұрын
@@braindeveloperdimensional5579 😂😂
@vladislavshevtsov143
3 жыл бұрын
WOW!!!!
Regex was the thing i avoided since start I finally understand them
guys, i watched this video like a year ago without typing and testing along and I was confused, but now because I opened that website alongside this youtube video, now its more easy to grasp and understand. watching alone doesn't help, you have to type along with the video.
Learning RegEx is one of the best skills I’ve ever learned. I use it extensively for prepping text for other uses, renaming files, especially music files, in programming, etc. Invaluable. Learn RegEx.
This made me laugh every time Preceded By flashed up on the screen. Awesome tutorial as always, thanks man.
Me: I watched it completely and it's cool bro! Also Me: trying to solve regex questions on my own. It sucks!
OMG. you are my savior man ! no way I could wrap my head around regex using the documentation. lost so much time on this ! "positive look forward" is CRAZY to split paths correctly; I needed that and I didn't even know ^^ THANK YOU
yea... I instantly went to you when I started learning this in my bootcamp. This is what I imagine learning to code to be like. A literal language.
Alright, now I will add Regex in my CV :')
I’m that one guy who answers all your Regex questions on Stack Overflow. You’re welcome.
@sidheshwartiwari9834
3 жыл бұрын
Lol
@derrickchen8898
3 жыл бұрын
Yoooo 😂
@mhb11
3 жыл бұрын
Thanks to you, I never learnt Regex
@glauberbispocruzcarvalho2235
2 жыл бұрын
thank you kind sir
Thank you so much. I needed to use regular expressions to work with a program, but it didn't have any tutorials and the regular expressions website is detailed but kind of a nightmare to learn from. This, however, was simple, concise, had everything I needed, and was so easy to learn from.
how are you explaining everything so simply it's unbelievable
This is so helpful for beginners! But we all know that when you have a task with regex, google is our best friend!
@WebDevSimplified
4 жыл бұрын
I almost always use regexr.com when I am working on a complex regular expression, since it makes testing so easy.
@ProgrammingwithPeter
4 жыл бұрын
@@WebDevSimplified yep
amazing,, and I'm still confusing about regex
@souvikkundu
4 жыл бұрын
I found this helpful kzread.info/dash/bejne/jJqFqLeDmLPXfbA.html and freeCodeCamp regex curriculum.
This is the best explanation of regular expressions I've seen! Thank you!
Thank you, it's been long since I've learned about regex expressions, but your tutorial really helped me remember and even learn new things! Very good 👏
Thanks man, it came right on time !!
The fat cat ran down the street. It was searching for a mouse to eat.
Had to watch this vid as part of the WDS Advanced Course Math Solver assignment. Once again a very clear explanation of a pretty hard topic. Thats why I follow you Kyle!
i was trying to understand how this f***in regex works for years, but just 20 mins with this guy and now i understand almost everything. Thank tyoiu so much Kyle
Please make on series React native and redux
i always had a love hate relationship with RegEx in my .net projects. i prefer simple logical coding to find a string patern.. but eventually it becomes a huge chunk of ifs and cases and includes... and i keep getting not perfect results... but is easy to write from scratch and read.. and then you have regex... you take hours to make the "search pattern" you keep googling and trying deferent online tools, and after that is a single line of code usually and work so much faster and has better results..but you cannot understand wtf it says after you revisit it few months later... 🙄🤣🤣🤣🤣
@tmcode2010
4 жыл бұрын
"get confused when you revisit" is the sad but true moment when using regex LOL
@gtc4189
4 жыл бұрын
That's why you simply put a comment above the RegEx explaining what it does. It's much easier to understand something if you know what its overall purpose is. If you really need to, you could also explain each individual portion of the RegEx, but that's often unnecessary.
@johnnyxp64
4 жыл бұрын
@@gtc4189 sure we do make comments... but when your code needs comments to explain it self (especially a single line of a weirdo regex) then there is something wrong with it. and whoever came up with the RegEx syntax must have been a stuborn mathimatician or similar and not thinking the user-friendly aspect of the syntax... which is almost non existent! 😂🙄
@gtc4189
4 жыл бұрын
@@johnnyxp64 That's not always true friend, RegEx's, especially super specific and complicated ones, can sometimes span hundreds of characters of length. Take this email regex for example: `(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])`. It can also get even worse! Especially when it comes to validating email addresses to an insanely specific extent, check THIS one out! www.ex-parrot.com/~pdw/Mail-RFC822-Address.html 😂😂😂😂😂
@johnnyxp64
4 жыл бұрын
@@gtc4189 so what I said is True! their syntax is terrible and you have to be a cryptographic machine to read that without any tool!🤯🤯🤯🤯
This was easier than I thought. Thank you!
Your video made regular exp much easier to understand, I was struggling with it a lot and tried to avoid it as much as possible. Thanks a lot.
What were the best spent 20 minutes of 2021? The ones on this video! Thanks, you made it very easy to understand.
This was the best explanation of regex I've ever heard. Thank you.
You have helped me learn so much. Now you help me review. I love your positive and informative mindset. It's like studying with a friend. You rock!
This was like a firehouse of information. While I may only end up using the first 5 mins of this video, it's very helpful.
Awesome tutorial, it took me over four times, and over two weeks of leisure time, to finish learning this tutorial and taking notes.
Best tutorials on regex ever found. Thanks a lot sir.
you ar an amazing teacher , i just watched my 1hr of uni lecture and had no idea what was happening and i came here 20 mins and its all easy cheers
Finally a regex explainer that makes sense! Thanks man.
Thank you bruh for this tutorial, I've had soo many training courses online/offline for regexp but this was the most informative one ever..... Helped me solve a lot of cases
Simple, clear, and to the point.
Amazing video my friend, so much value. What I would like to add, is that the viewer needs to have 90% grasp on each one of the concept you explained here or else this summary will just go over the viewer's head. This video helped me solidify/reinforce/validate what I already knew, which is extremely useful. Made me aware of things that I don't know yet. And helped me see the big picture. Which is encouraging/motivating because I can see the light at the end of the tunnel. However I only go all this value, because I have spend around 10 hours trying to understand Regular Expressions on Free Code Academy (and you make great content). Thank you so much for the Amazing content.
simple, clear, and amazing Thank you so much !
Thanks for the explanation! Very clear and useful!
This video is good for understanding the terminology for beginners who would like to know what's in Regex. And for people who forget things like me it would be a good recap. But practice is must .
I already had some knowledge on the basics of Regex, but not about lookahead/lookbehind, it very is clear now, thanks a lot!
A few years since you did this video I know, but it is exactly what I needed, Awesome job Brian. I am just training up on SIP & MS Teams phone systems with direct routing, which requires a bit of knowledge for E164 translation. The phone systems use expressions for pattern matching and translation of in and outbound dialed numbers. You information has and will be invaluable, thanks buddy!
I have goosed (GOOgled-for-examples-and-then-uSED) RegEx for a few years every now and then, but your video really made it click in my brain! Thank you! ...I think I'll have to double check my previous work now.
This is exactly what I need mate. Thanks a ton!
this morning i was doing an algorithm and needed to clean a string and i finally did it with this video It's really easy and i undestood more than 80 % Thanks in advance
This video taught me more about regex than the whole semester of webdev class at university
Thank you for taking your time to simplify regex
Thanks a lot for this tutorial. I used to be scared of regex before, but no more!
It's clear, simple and helpful. Thanks for sharing.
Awesome. Simple and to the point. Great stuff !!!
Within minutes of watching this, I was blowing friends away with this instead of ifs and loops because of how you explained this. Thanks man!
Thank you for this great and simple video.
amazing video. I literally didn't know regex at all before this vid, but after it was done I was able to find and replace using regex patterns. thanks.
Awesome ! Covers everything in such a crisp way
Wonderful video. I love the way you explain and out together everything.
I was trying to learn this from a book that spent zero effort explaining the purpose of the slashes on RE, or when you want to use a back verses a forward. Thanks for the vid
The cheat sheet on the website you recommended is everything
Beautifully Simplified! Thanks a lot man...
You really did a great job here. I needed to see this today and you really helped explain the “how” for me.
one of the best videos for regex. good coverage overall. thanks.
This was the most helpful video I have found on the subject. Thank you!
this is the best tutorial about regx that i've ever seen
Wow! Thank you so much. I totally understand and have a solid basis in Regular Expressions now. Kudos! to more great content. This deserves a sub! All the best.
Really awesome, you help me to solve a problem that I would say it is difficult but thanks to you pal, everything went easy as your explanation !!
Ive begun to learn...that the deeper you get into these programming languages ....The more you are gonna have to learn by trial and error! but a good foundation in the basics will go a long way!
Thanks man, i always had difficulty validating some strings , writing programs for interpreting commands .
Thank you! Creating complex regEx is still a mistery for, but the page you showed can really help. For now I will create a few simple rules and combine them together in my code.