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

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 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 9 หลายเดือนก่อน

      d-ddd-ddd-dddd

    • @sugaslate14
      @sugaslate14 หลายเดือนก่อน

      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!

  • @RevanthBysani
    @RevanthBysani ปีที่แล้ว

    Great examples and use cases. Well done!

  • @christofferds
    @christofferds 11 หลายเดือนก่อน

    The Best I’ve found so far. Thanks

  • @MethodOverRide
    @MethodOverRide ปีที่แล้ว

    Exactly what I was looking for!! 👌

  • @sifrk
    @sifrk 2 ปีที่แล้ว +1

    Very comprehensive. Thank you!

  • @curious5972
    @curious5972 ปีที่แล้ว

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

  • @hiuller
    @hiuller 2 ปีที่แล้ว +3

    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 10 หลายเดือนก่อน

    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 8 หลายเดือนก่อน

    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 7 หลายเดือนก่อน

    ❤❤❤

  • @berndeckenfels
    @berndeckenfels ปีที่แล้ว +1

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

  • @gizmovids
    @gizmovids ปีที่แล้ว

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

  • @QuotePilgrim
    @QuotePilgrim 5 หลายเดือนก่อน

    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