Regular Expressions (Regex) in JavaScript – tutorial




Learn the basics of using regular expressions / regex in your JavaScript applications.

Check out Cody Seibert’s main channel: https://www.youtube.com/channel/UCsrVDPJBYeXItETFHG0qzyw

Learn to code for free and get a developer job: https://www.freecodecamp.com

Read hundreds of articles on programming: https://medium.freecodecamp.com

And subscribe for new videos on technology every day: https://youtube.com/subscription_center?add_user=freecodecamp

Original source


12 responses to “Regular Expressions (Regex) in JavaScript – tutorial”

  1. @7:27 bit confused as to why that doesn't match. "'There's no character [a-z] here." I agree, but if you remove the whitespace & 'and' at the end of the sentence, it will match

    why does 0 or more [a-z] characters get ignored when at the end of a sentence, but not in the middle?

    eg:

    my name is 0 and i'm 34

    /my name is [a-z]*/ — matches "my name is"
    /my name is [a-z]* and/ — doesn't match anything

  2. this was interesting, but I'm searching for a secret of matching titles in an app. A few song titles are one word, but most have several words. In the app, I'd like for the spaces between words to be either ignored or not have the JavaScript eliminate the space once it was recognized as a match. I'm not sure if the problem is regex or getting JavaScript to play ball.

Leave a Reply