Regular expressions (or Regex) are patterns used to match character combinations in strings. In this crash course tutorial, you will learn how to use regular expressions in JavaScript. You will be able to apply the concepts to any programming language.
This course follows along with the free regular expressions curriculum at freeCodeCamp.org: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions
You can also view this course on Scrimba.com: https://scrimba.com/g/gregularexpressions
⭐️ Contents ⭐️
⌨️ (01:04) Using the Test Method
⌨️ (02:15) Match Literal Strings
⌨️ (02:57) Match a Literal String with Different Possibilities
⌨️ (03:46) Ignore Case While Matching
⌨️ (04:45) Extract Matches
⌨️ (05:32) Find More Than the First Match
⌨️ (07:16) Match Anything with Wildcard Period
⌨️ (08:54) Match Single Character with Multiple Possibilities
⌨️ (10:14) Match Letters of the Alphabet
⌨️ (10:04) Match Numbers and Letters of the Alphabet
⌨️ (12:15) Match Single Characters Not Specified
⌨️ (13:32) Match Characters that Occur One or More Times
⌨️ (14:19) Match Characters that Occur Zero or More Times
⌨️ (15:32) Find Characters with Lazy Matching
⌨️ (18:54) Find One or More Criminals in a Hunt
⌨️ (19:58) Match Beginning String Patterns
⌨️ (20:53) Match Ending String Patterns
⌨️ (21:40) Match All Letters and Numbers
⌨️ (22:48) Match Everything But Letters and Numbers
⌨️ (23:35) Match All Numbers
⌨️ (24:04) Match All Non-Numbers
⌨️ (24:40) Restrict Possible Usernames
⌨️ (27:29) Match Whitespace
⌨️ (27:56) Match Non-Whitespace Characters
⌨️ (28:25) Specify Upper and Lower Number of Matches
⌨️ (29:40) Specify Only the Lower Number of Matches
⌨️ (30:10) Specify Exact Number of Matches
⌨️ (30:47) Check for All or None
⌨️ (31:38) Positive and Negative Lookahead
⌨️ (35:09) Reuse Patterns Using Capture Groups
⌨️ (40:18) Use Capture Groups to Search and Replace
⌨️ (43:18) Remove Whitespace from Start and End
🎥 Course created by Beau Carnes. Follow Beau on Twitter: https://twitter.com/BeauCarnes
—
Learn to code for free and get a developer job: https://www.freecodecamp.org
Read hundreds of articles on programming: https://medium.freecodecamp.org
And subscribe for new videos on technology: https://youtube.com/subscription_center?add_user=freecodecamp
source
perfect !
Last task you can do without replace
/[^s].+[^s]/
the solution at 34:58 is not correct and the original challenge throws an error if I use 5 instead of 6 when testing string '12345'. let me know if this is a misunderstanding 🙂
This is a really good tutorial
Got a deeper understanding of RegExp
35:07 regex doesn't work in case of less than 5 chars console.log(/(?=w{5})(?=D*d{2})/.test("ast99")) and returns true.
" Hello World ".replace(/^s+(.*)s$/,"$1")
I failed the last challenge. lmao, I forgot to use the g flag
Thanks Beau;
I think at 36:40 there is mistake.
He says that replacing 1 is just to avoid rewriting (w+)
However
/(w+)s1/ tests TRUE for "regex regex" but FALSE or "regex somethingelse"
/(w+)s(w+)/ tests TRUE for "regex regex" but TRUE for "regex somethingelse"
7:22
Regex is the criminal !
at Restrict Possible Usernames 24:40
if the string is three characters (one letter and two numbers ) it will get false
so the expression should be /^[A-Za-z]{2,}d*$ |^[A-Za-z]{1,}d{2,}$/
34:48 For anyone confused why he didn't put a comma after the 2 for “two *or more*” it’s because it is in a lookahead: it only needs to see two digits and then it can stop looking because then we know there are at least two.
Thank you Beau , much appreciated thing !
This is certainly an informative video however it is not a beginner's video due to how fast paced it is and the assumption that some prerequisite knowledge is present. In this case JavaScript. Nonetheless it is a good tutorial for people who want to refresh their knowledge on this particular area.
35:00 "This is going to match for 5 or more characters". Noob question: doesn't the {5} mean it's going to match EXACTLY 5 characters?
Be me, find a video, Beau is the narrator, leave understanding everything about rejects
Thanks for the video, but I think you are mistaken or misspoke on the reuse pattern using capture group. You stated that if you replace the 1 with the same capture pattern that it would be the same thing. I believe that is a mistake, for example use repeatstring. If you replaced the 1 with (w+) then Yes it would match the string, but it would also match “regex testing” and I don’t think that is what you are trying to do.
Great clear and concise teaching. Great video . Thanks
You guys are using Seinfeld vision from 30 Rock😁
Step 1- learn regex
Step 2- forget regex
Step 3- realize you still need to know regex, frantically try combinations on regexr until you get what you need.
The '' character is a backslash, not a slash. Also, the '*' is an asterisk (notice how it's spelled), not an "asterick".
Next, Adam Sandler should narrate functional programming
33:50 I'm lost….
How to Find a regular expression that matches the last two columns of the file. ?
How to Find a regular expression that matches the last two columns of the file. ?
How to Find a regular expression that matches the last two columns of the file. ?
How to Find a regular expression that matches the last two columns of the file. ?
How to Find a regular expression that matches the last two columns of the file. ? PLEASE HELP
Good video, really, thanks!
When I first got to do with Regex I hated it. Now that I begin to understand it, I'm kinda starting having fun lol
39:18 bruh what. Why would it match the space after the third '42' when the last element is any digits?
At 43:22, why doesn't /^(s+)1$/.test(' Hello, World! ') equal True? Can someone explain this to me pls?
This is the one i needed, thanks mam it's helped a lot.
how many times am I going to forget everything and come back to learn it again? Step by step is simple. putting it together is hard, and remembering what random letters do is simply not going to happen. Anyone got a way to memorize this or am I SOL?
First time i watched this video gave me headache lucky i watched few more times and practice while video was playing
Nothings hard you are just not familiar