How to Write Regular Expressions Without Going Crazy (Beginners Tutorial)

Поділитися
Вставка
  • Опубліковано 8 лип 2024
  • Order the NEW Tinker Project Ultimate Dev Kit Here 👉 tinkerprojects.dev
    Learn Regular Expressions with this masterclass tutorial.
    Every programmer should have a good handle on how to wield this powerful tool. Knowing how to read and write regular expressions will greatly enhance your ability as a programmer to navigate and extract complex data structures with ease. This video will deep dive into all the underlying mechanics and syntax around regex as well as provide real world examples of how to implement this with JavaScript and python to build web scrapers, email validation, and front end password validators.
    Outline
    Intro 0:00 - 01:42
    Constructing a Regex 1:42 - 2:30
    Literal/Special Character 2:30 - 2:50
    Special Characters 2:50 - 4:25
    Shorthands 4:25 - 5:15
    Anchors 5:15 - 6:24
    Repetition 6:24 - 9:06
    Capture Groups 9:06 - 12:40
    Character Classes 12:40 - 14:46
    Negated Character Class 14:46 - 16:30
    Back References 16:30 - 18:06
    Search and Replace 18:06 - 19:17
    Positive Look Ahead 19:17 - 20:13
    Negative Look Around 20:13 - 21:40
    Flags and Modifiers 21:40 - 22:30
    Match on Email Addresses 22:30 - 24:35
    JavaScript Regex 24:35 - 32:00
    Password Validation 32:00 - 34:06
    Web Scraping 34:06 - 39:27
    Python RE Package 39:27 - 40:38
    #regex #regularexpression
    Regex Validator
    regex101.com/
  • Наука та технологія

КОМЕНТАРІ • 31

  • @DataSlayerMedia
    @DataSlayerMedia  2 роки тому +9

    Pop Quiz: What does this regex look for? \d-\d{3}-\d{3}-\d{4}

    • @sandeepagarwal7387
      @sandeepagarwal7387 2 роки тому +4

      Phone Number with single-digit country-code (n-nnn-nnn-nnnn) or 1-800... or 1-888... kind of phone numbers

    • @cybersamurai99
      @cybersamurai99 10 місяців тому

      d-ddd-ddd-dddd

    • @sugaslate14
      @sugaslate14 3 місяці тому

      A digit followed by a dash followed by 3 digits followed by a dash followed by 3 digits followed by a dash followed by 4 digits
      A phone number with country code lol

  • @pixelrangerstudio86
    @pixelrangerstudio86 Рік тому +4

    i watched COUNTLESS videos and read the entire internet... and after your video i FINALLY managed to comprehend and use regex!!! milion thanks!

  • @caiodavi9829
    @caiodavi9829 Рік тому

    finally a video that actually teaches regex !! big thanks, mate!

  • @christofferds
    @christofferds Рік тому

    The Best I’ve found so far. Thanks

  • @RevanthBysani
    @RevanthBysani Рік тому

    Great examples and use cases. Well done!

  • @MethodOverRide
    @MethodOverRide Рік тому

    Exactly what I was looking for!! 👌

  • @curious5972
    @curious5972 Рік тому

    Thank you ❤️🥺🙏. After 2 months of browsing i found this video . salute for sharing this level of knowledge about ragex 👌🤝

  • @sifrk
    @sifrk 2 роки тому +1

    Very comprehensive. Thank you!

  • @hiuller
    @hiuller 2 роки тому +4

    Besides being very helpfull, great content and explanation, it is also very good to watch on a mobile phone! While some screen capturing tutorials are too small, you did an amazing job!

  • @TiffanyNg100
    @TiffanyNg100 2 роки тому +2

    really useful and with real life practice

  • @wilkobriele9313
    @wilkobriele9313 Рік тому

    Thanks for that overview!
    I couldn't figure out how to solve the following problem:
    I have a string (sql command) containing questionmarks. (related to prepared statements) Now I want to find every questionmark, but not those which are part of a quoted substring.
    Example pseudo sql string:
    select "here is ? within quotation marks", 'here is ? within single quotation marks' from tablexxx where id = ? and col = ? limit ?,?
    In the upper line I don't want to get the first and the second questionmark, but the last 4 questionmarks.
    Do you have an idea to solve it? Thank you :)

  • @akya
    @akya 11 місяців тому

    great video and I understood mostly but how does one remember all of this lol...its like i forget it all till the next time i have to use regex

  • @user-jq9cr7oy6x
    @user-jq9cr7oy6x 9 місяців тому

    I want to learn how to insert a   where ever there is a space before or after a number. For example May 21 or 25 people on 13 boats. So add a   before and after 21,25 and 13.

  • @supriyadara6075
    @supriyadara6075 2 роки тому +1

    My requirement that regex should allow any local language characters, numbers and some special characters in angular

  • @ItihasMarg
    @ItihasMarg Рік тому

    Hi can you please help me to create regex for password...
    Two condition---
    1) Password should contain at least one uppercase, lower case, digit, special char.
    2) password should not have above items next to each other..
    eg. P@sSword12$
    This should not allow because wo and 12 are next to each other..
    PlE3@s0 This should allow

  • @alexgavril6875
    @alexgavril6875 2 роки тому +1

    Let's say I have the example: 12345 If I type \d\d it does not detect 45. It only detects 12 23 34. Any idea why?

    • @DataSlayerMedia
      @DataSlayerMedia  2 роки тому

      The pattern is explicitly looking for two sequential digits, the number of times it matches is dictated by whether or not the "g" or global flag is set. But \d\d is not proper, either do \d+ or \d* or \d{2}

    • @alexgavril6875
      @alexgavril6875 2 роки тому

      @@DataSlayerMedia \d{2} not matching 45 either .....confused what's the logic behind this language...

    • @freizagen
      @freizagen 2 роки тому

      @@alexgavril6875 Try this (\d\d)+$ and you will understand

    • @wilkobriele9313
      @wilkobriele9313 Рік тому

      @@alexgavril6875 you are asking for 2 digits. It starts at the first place (that is 1) the following also is a digit, so you get 12. Now it starts with 3... you get 34. Now it starts with 5, but there is no following digit, it doesn't match again.
      That is how notepad++ handles it. Note: I don't get 23 as a match because the 2 belongs to the first match.

  • @rahneshin752
    @rahneshin752 8 місяців тому

    ❤❤❤

  • @gizmovids
    @gizmovids Рік тому

    Data Slayer: where do you prefer cash tips? via- the "thanks" button? If elsewhere, maybe tell us here? www.youtube.com/@DataSlayerMedia

  • @berndeckenfels
    @berndeckenfels Рік тому +1

    Don’t ever use a Regel to validate an email address without checking the standard or use a ready made validator

  • @QuotePilgrim
    @QuotePilgrim 6 місяців тому

    Bro pretending lookbehinds aren't a thing lol.

  • @saj-softmakeiteasy9177
    @saj-softmakeiteasy9177 Рік тому

    Hellow ''', i need some help on Autohotkey , how i can read line from text without adding line number.
    for example here tha ,, dat.txt
    i need to display on messagge Sure Name Value = fg
    using filereadline or RegExMatch
    Name
    ABCD
    Sure Name
    fg
    Place
    US