Validate IP Address | Regex | Leetcode

Поділитися
Вставка
  • Опубліковано 3 січ 2025

КОМЕНТАРІ •

  • @abhinav9469
    @abhinav9469 4 роки тому +47

    U decided to teach the whole logic and solved the purpose of this question. Brilliant explanation

  • @BaishaliGhosh13
    @BaishaliGhosh13 4 роки тому +20

    I've always found regexes a bit confusing and just tend to look them up when I need to. Appreciate the patience with which you do these problems. It helps so much in building understanding of approach to solution unlike some channels which just walkthough algos. We need to build problem solving skills and not memorization. Content quality and teaching style is awesome.

  • @ShivamPanchbhai
    @ShivamPanchbhai 3 роки тому +4

    this is the first, last and best video I have ever seen on Regex

  • @ArpitDhamija
    @ArpitDhamija 4 роки тому +11

    tomorrow is my code-nation interview, kaash yahi puchle voh . You are amazing man, learnt a lot of things as it was the first time doing regex. Best coding channel ever found

  • @davronkarimov2125
    @davronkarimov2125 4 роки тому +4

    I think this crash course on regex is concisely packed with good content.
    Big thanks to author!

  • @ak9tgaming714
    @ak9tgaming714 Рік тому +3

    Correction:
    It seems like you may be looking for a pattern that specifically matches the sequence ab repeated one or more times. If that's the case, you should use the regular expression (ab)+ , not [ab]+.
    The regular expression [ab]+ will match any string that contains one or more occurrences of either a or b. The + sign specifies one or more occurrences, and the [ab] specifies a character class, which matches any character that is either a or b.

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

      Exactly, I was thinking the same. Thanks for this correction.

  • @ayushisinghal2339
    @ayushisinghal2339 4 роки тому +3

    Loved this explanation. This is the first time ever that I have understood regex and that too so well. Thanks a lot.

  • @mansiagrawal4039
    @mansiagrawal4039 4 роки тому +3

    A big fan of the way of explaining your videos, sir. Understood it very well. Thank you for making us not hate coding.

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

      Not hate coding! 😅 Welcome 😀

  • @sagardafle
    @sagardafle 4 роки тому +3

    I'm amazed at the way you taught this. You started with a simple regex to eventually build the logic for the main problem.
    Kudos and thank you for this explanation.
    I felt sorry for you at the end when you had to rush as it seemed you were worried about video length. But let me tell you a good student/follower wouldn't mind lengthy but useful explanation.
    Thank you once again.

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

    this is the most clear explanation of regex formation for validation.

  • @venothanand91
    @venothanand91 4 роки тому +1

    Awesome. Initially I have solved it with the straightforward approach using conditional operators and string operators. But solving it with regex was more reliable and efficient. Thanks for your efforts.

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

    Brilliant , I learnt Regx in one video + solved a leetcode question , Thanks a lot sir

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

    I always search your channel for any complex problem explanation and u never disappoint me with ur excellent explanation approach.thanks😀

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

    Best Regex Video ever made. Thank You.

  • @prateeksrivastava1577
    @prateeksrivastava1577 3 роки тому +1

    The best REGEX Explanation Ever....!!!! Great Teaching Skills..... :)

  • @rishabhkumar8115
    @rishabhkumar8115 3 роки тому +2

    i like your teaching. The way you cleared the suspensive doubt. I really appreciate your work.

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

    OMG! Your explanation is AMAZING! It is clear and very easy to understand. Thank you, Sir!

  • @shreyandey6089
    @shreyandey6089 4 роки тому +1

    Regex library for validating an IP is totally explained.
    Excellent explanation dude;!

  • @arsalalam5998
    @arsalalam5998 4 роки тому +1

    was looking all around for some explanation on regex syntax. thanks man.

  • @amrita7444
    @amrita7444 3 роки тому

    Thnkyou, I could find regex pattern but not explanation anywhere. Now its registered in my mind.

  • @kotinitirumula
    @kotinitirumula 4 роки тому +1

    U r awesome in regular expression . It cleared my all doubt of regular expression

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

    Best and fruitful video for regex

  • @muhammedjack8303
    @muhammedjack8303 4 роки тому +1

    I kept this video in my favorite list
    and thanks for the excellent explanation

  • @nikhilkakade7022
    @nikhilkakade7022 3 роки тому

    I understood sir , simple explanation,thnx for this

  • @LinoLowLevel
    @LinoLowLevel 3 роки тому

    Thankyou brother, you explaining me about REGEX

  • @gugun23
    @gugun23 4 роки тому +1

    Thanks for such a detailed explanation. I was searching for some explanation like this. Awesome presentation. Keep it up....

  • @MaheshKumar-yz7ns
    @MaheshKumar-yz7ns 4 роки тому +1

    Just Amazing.....just Amazing...

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

    Nice Explanation

  • @travelandtaste11
    @travelandtaste11 4 роки тому +1

    Love you brother................a lot of thanks

  • @prashantranjan3777
    @prashantranjan3777 4 роки тому +1

    superb explanation. Thank you

  • @shresthmishra9329
    @shresthmishra9329 4 роки тому +4

    i didn't know giving spaces betweeen OR operator ( | ) will not throw an error but will always return "Neither" as the answer.
    Thanks for explaining regex. TBH i heard it for the first time.

    • @techdose4u
      @techdose4u  4 роки тому +1

      Learner something new :)

    • @sravanbodha2686
      @sravanbodha2686 4 роки тому

      @@techdose4u bro can you please solve the last year codevita' s atm problem. Any help would be grateful.

  • @vasanthinatarajan4674
    @vasanthinatarajan4674 4 роки тому

    Really it is helpful to me while learn first time about the concept...hats off

  • @otifelix
    @otifelix 4 роки тому +1

    Excellent explanation on question and on regex

  • @shubhalihiran4966
    @shubhalihiran4966 3 роки тому

    you are just amazing....thank you so much

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

    best explanation. mainly regex part. thanks

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

    Wow! That was a fantastic concept

  • @kunalsoni7681
    @kunalsoni7681 4 роки тому +1

    Thank you 😊 so much sir .. This video is really Very helpful to identify validation of ip address 😊☺️

  • @rishibhardwaj1734
    @rishibhardwaj1734 3 роки тому

    Best explanation, thanks for the Video ❣️

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

    Thanks for regex concepts....

  • @shivammaniharsahu1228
    @shivammaniharsahu1228 3 роки тому +1

    super se bhi upper explanation

  • @aniketmasram6500
    @aniketmasram6500 3 роки тому

    I think I found +1 great channel ✨

  • @shobhagm
    @shobhagm 3 роки тому

    So good. Excellent!

  • @systemforge
    @systemforge 3 роки тому

    absolutely brilliant ❤️ terrific explanation 🔥🔥

  • @kushgupta6416
    @kushgupta6416 4 роки тому

    very well explained. now i know regex also :-)

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

    What program are you using to do that presentation?
    It is really cool!!!!
    Thanks for the video!

  • @hapysethi1306
    @hapysethi1306 4 роки тому +1

    Bro boht boht sukriya iski kafi zarurat thi

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

    I am sure I will not forget Regex anymore:)

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

    thank you for the clear and detailed explanation!

  • @thunderbolt8632
    @thunderbolt8632 4 роки тому +3

    Loved the video!Sir can u please guide us how are you so consistent in ur work,It would really help us all!

    • @techdose4u
      @techdose4u  4 роки тому

      Because I love to do it. That's all.

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

    Simply Amazing !!! Thanks !!

  • @anmolwadali9227
    @anmolwadali9227 4 роки тому +1

    really gud question and great explanation

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

    Amazing explanation....

  • @simagupta3299
    @simagupta3299 4 роки тому +1

    Great explanation 😀 thanks

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

    Why subscriber count of this channel is so less.. 😧😧 It is one of best channel available on ytb

    • @techdose4u
      @techdose4u  4 роки тому

      😅

    • @kishankumargupta4200
      @kishankumargupta4200 4 роки тому +1

      @@techdose4u Don't worry the subscriber count will increase fast. You need to just make more videos of codeforces/CodeChef contests also because many people take that contest.

  • @aniketmasram6500
    @aniketmasram6500 3 роки тому

    Thankyou soo much sir ,so easy and Great explanation.

  • @md_aaqil8027
    @md_aaqil8027 4 роки тому +3

    Good Explanation in Planet

  • @venkateshn9884
    @venkateshn9884 4 роки тому

    Once again proved...u r ultra legend bro

  • @Rohitkumar-tx6jl
    @Rohitkumar-tx6jl 3 роки тому +1

    Excellent explain

  • @i.vigneshdavid1698
    @i.vigneshdavid1698 4 роки тому +1

    Simple and Clean👍👍

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

    Thank you very much 🙏

  • @marvellouschandan
    @marvellouschandan 3 роки тому +1

    It worked, really thanks :)

  • @VishalKumar-pk9ek
    @VishalKumar-pk9ek 4 роки тому +1

    you should write a book😍😍😍
    unmatchable content👍

  • @indianking0017
    @indianking0017 4 роки тому +1

    Keep updating u make things soo easy

  • @parikshit2178
    @parikshit2178 4 роки тому +1

    Amazing Work!

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

    Boooooooooooooooom Big thanks🥰🥰🥰🥰🥰

  • @siddhartha.saif25
    @siddhartha.saif25 4 роки тому +1

    thank you so much!

  • @savigoyal2385
    @savigoyal2385 4 роки тому +1

    perfect explanation

  • @bharghav9041
    @bharghav9041 3 роки тому +1

    [1-9][0-9]{2}-----> for all three digit numbers, not for four digit numbers at 12:02

    • @techdose4u
      @techdose4u  3 роки тому

      Yea right :)

    • @muhammadradwan74
      @muhammadradwan74 3 роки тому

      For [1-9][0-9]{2}
      You mean by "three digits" it will repeat only for the bracket [0-9] and not the [1-9] ??

  • @nikhilkakade7022
    @nikhilkakade7022 3 роки тому

    can we add "." at the end of string so that it could handle last expression also?

  • @shubhamagarwal2998
    @shubhamagarwal2998 4 роки тому +1

    🔥🔥🔥💥🤘🤘 awesome video

    • @techdose4u
      @techdose4u  4 роки тому +1

      Thanks bro :)

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

      Till now I don't aware of this method thanks for explaining new topic which is ignored normally

  • @midhileshmomidi2434
    @midhileshmomidi2434 4 роки тому +1

    I think yours is the only channel which explained in regex bro
    Regex takes very less time
    If I am not wrong in this code it is O(1) as there are greedy quantifiers here
    Please correct me if I am wrong

    • @techdose4u
      @techdose4u  4 роки тому +1

      Time complexity won't be O(1) because expression matching parses the string. I don't use regex as don't face problems where I should use it but you can go through the regex on official website and get the internal working of this. Then everything will be clear.

  • @subhadippatra7930
    @subhadippatra7930 4 роки тому

    If the regex is [ab-ca] , in that case will all of ab, bc,ca be valid or not ?

  • @nabarthini
    @nabarthini 4 роки тому +1

    what about when we encounter a :: case in ipv6 address?,how is that handled?

    • @techdose4u
      @techdose4u  4 роки тому

      Every colon is preceded by 1 to 4 digit number. That is already present in regex formula.

    • @nabarthini
      @nabarthini 4 роки тому

      @@techdose4u no I meant in a ipv6 address like 12::45ef

  • @amanaswal11
    @amanaswal11 4 роки тому +1

    This video is amazing!

  • @nagababu-kr4zr
    @nagababu-kr4zr 3 роки тому

    One doubt. Why we have to take range 200-249 and 250-255 ? Why can't we take 2[0-5][0-5] for 3 digits?

  • @laraibkamalasdar6837
    @laraibkamalasdar6837 5 місяців тому

    Can someone explain me where in this regex pattern of v4 its checking that it will not start from 0

  • @yuktikhantwal2342
    @yuktikhantwal2342 4 роки тому +1

    sir, what approach will be expected for this question in an interview? will the interviewers expect us to know this technique?

    • @techdose4u
      @techdose4u  4 роки тому +1

      No. I don't prefer regex because I can't remember. So use something less optimal or using if-else.

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

    12:07 for those who know regex and are in for just the solution of the problem.

  • @anmolwadali9227
    @anmolwadali9227 4 роки тому +1

    is regex library allowed on all coding tests?

    • @techdose4u
      @techdose4u  4 роки тому

      If STL is allowed then regex will be allowed.

  • @SomnathDas-fg2qc
    @SomnathDas-fg2qc 4 роки тому +1

    bro thank u for giving details knowledge of regex function,but i have bit doubt that after making three digit i.e1(0-9)(0-9) cann't we make a range directly from 200 to 255?here u are spliting it i.e from 200 to 249 and then 249 to 255

    • @techdose4u
      @techdose4u  4 роки тому

      You can't make for the 3rd digit. Just try it :) You will get it once you write.

    • @SomnathDas-fg2qc
      @SomnathDas-fg2qc 4 роки тому

      @@techdose4u no i am telling that why u have split it up into two things,that is from 200 to 249 and 249 to 255

    • @tilakrajrao2753
      @tilakrajrao2753 4 роки тому +1

      bro we need to split 200-255 into 200-249 and 250-255 because if you write 2[0-5][0-5] instead of splitting then your regex will fail for integers like 219,238 etc as highest limit is till 5 only ...i hope you got my point.

  • @abhinandanjain3961
    @abhinandanjain3961 3 роки тому

    Sir my one doubt is that sir you do not consider 000.038.098.098 (MEANS ZERO ) is not consider to be an ip address but on hackerrank they have consider a zero (000.12.12.034) is an ip . So sir our coding consider to be this will be wrong ? Sir please tell related to this problem coding also

  • @harinaaraayans3453
    @harinaaraayans3453 4 роки тому

    sir what writing software do you use sir?

  • @michaellieberman114
    @michaellieberman114 4 роки тому

    Brilliant explanation! Perfect. Learning this was crucial for the future. Do you mind if I share this?

    • @techdose4u
      @techdose4u  4 роки тому

      Where will you share?

    • @michaellieberman114
      @michaellieberman114 4 роки тому

      @@techdose4u various social media like FB, or individual contacts who would benefit.

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

    loved the explanation sir , sir i am not able to implemment it in my python code the same regex pattern over there is giving me differnt result, i want to extract IP adresses from a log file
    Thanks Sir

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

    Y do we need 25[0-5] and y cant we stop at 2[0-5][0-5]

  • @HelloWorld-qx1lo
    @HelloWorld-qx1lo 4 роки тому

    Goog work! Nice explanation.
    But, about IPv6, do you really need to escape colon (:)?
    ([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4})
    But your solution will be accepted, because, there is no special characters in the input string
    Any way, great job!

  • @travelandtaste11
    @travelandtaste11 4 роки тому +1

    brother your pattern does not work on hackerrank

    • @techdose4u
      @techdose4u  4 роки тому

      Can you mention the problem ?

  • @sakshisingh9706
    @sakshisingh9706 4 роки тому +1

    you are amazing:)

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

    Will this works for Python?

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

    we can also do it by using getline an delimiter technique...

  • @madhavsahi7400
    @madhavsahi7400 4 роки тому +1

    Sir when will you make DP playlist ? From basics ?

    • @techdose4u
      @techdose4u  4 роки тому +1

      Will make videos topicwise. Let me first get this challenge over with.

    • @madhavsahi7400
      @madhavsahi7400 4 роки тому

      @@techdose4u Ok sir

  • @sungjinlee4579
    @sungjinlee4579 4 роки тому +1

    you don't need the escape character for the colon.

  • @ChristianESL
    @ChristianESL 4 роки тому +1

    Good explanation. My only feedback, regex are a higher level. Internally they parse the string and use recursivity. I saw most answers on leetcode parse the string and none used regex.

  • @dipan246
    @dipan246 4 роки тому

    2[0-4][0-9]{2} ---> Matching 4 digit numbers. For 6 digit numbers we have to write 2[0-4][0-9]{4}. Please explain sir...
    >>> re.search(r"(2[0-4][0-9]{2})","248201")
    >>> re.search(r"(2[0-4][0-9]{2})","248201").group()
    '2482'
    >>>

  • @MrKhan-ci3uy
    @MrKhan-ci3uy 3 роки тому +1

    Sensei😍

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

    10:53 Repeat Expression - explanation and examples are wrong. Eg. [1-9][0-9]{2} - This will not validate 4 digit number. It'll validate 3 digits numbers only. Also 2[0-4][0-9]{2} will not validate 6 digit number; only 4 digit numbers are validated.

  • @subhadippatra7930
    @subhadippatra7930 4 роки тому

    Is [0-9 a-b] same as [0-9 | a-b ] ?

  • @mayer5155
    @mayer5155 Місяць тому

    Why use 2[0-4][0-9]|25[0-5] instead of 2[0-5][0-5]

  • @MohacelHosen-cd8iz
    @MohacelHosen-cd8iz Рік тому

    [abc] and [a-c] both are same. 🤔🤔
    import java.util.regex.Pattern;
    public class Test {
    public static void main(String[] args) {
    String input="aabbccca";
    String pattern1= "^[abc]+$";
    String pattern2= "^[a-c]+$";
    Pattern compile1 = Pattern.compile(pattern1);
    Pattern compile2 = Pattern.compile(pattern2);
    boolean bothAreSame = false;
    if (compile1.matcher(pattern1).find() == compile2.matcher(pattern2).find()){
    bothAreSame=true;
    }
    System.out.println("Both are same::"+bothAreSame);
    }
    }

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

    Nice explanation