Regex day 2 - Extracting matches

Поділитися
Вставка
  • Опубліковано 15 жов 2024

КОМЕНТАРІ • 16

  • @DataVisualisation
    @DataVisualisation 4 місяці тому +1

    really good explanations and tips!!! Everyone now knows what they can / must focus on if they need this function. Your videos are not too long! They are detailed.

    • @DimEarly
      @DimEarly  4 місяці тому +1

      I salute your attention span. 🫡 It’s a rare commodity these days.

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

    Woah! We got a great presentation of these new functions! Thanks a lot that your videos!

  • @IvanCortinas_ES
    @IvanCortinas_ES 4 місяці тому

    That's caviar. Thank you!!!

  • @GregHingsbergen
    @GregHingsbergen 4 місяці тому

    Great point from ~1:30! If you don't understand regex you won't be able to realize what all it is capable of!

  • @richardhay645
    @richardhay645 4 місяці тому

    Got it! Extremely helpful. Thanks.

  • @viktorasgolubevas2386
    @viktorasgolubevas2386 4 місяці тому

    Thanks a lot for diving into and sharing!

  • @Harryjackgross
    @Harryjackgross 4 місяці тому

    Informative & useful as always!
    For the bracket stuff, if you want to do infinite bracket and bracket rules this violates the pumping lemma so regexand you need a language of CNF or equivalent strength - although this is worth checking as a that might just be DFAs (but off the top of my head it is all regular languages)
    For this specitic case where you want just a single pair you can just do an or of (123) and 123

    • @DimEarly
      @DimEarly  4 місяці тому +1

      It's great how much you can learn in an afternoon of googling a new topic, but it's also good to have someone who actually knows what they're talking about to chip in now and again! 😂

    • @Harryjackgross
      @Harryjackgross 4 місяці тому

      @@DimEarly Re-reading this perhaps I should have proof-read it 😂 I've checked now and indeed regex is a regular language so due to the pumping lemma you can't have infinite matching brackets, but can get finitely many with lots of OR!

  • @E_Pats
    @E_Pats 4 місяці тому +2

    Great videos as ever, Dim. Concerning 9:55, we can do this drawing on the capture groups. I would go with:
    (\()?\d{3}(?(1)\))[- ]?\d{3}[- ]?\d{4}
    Very similar to yours - to break down the differences:
    (\()? - this the same as your \(? at the start, but turns it into capture group #1 so we can reference it later.
    (?(1)\)) - this says "If capture group #1 matched, we want a close bracket". You can get fancy with this with (?(group #) value if matched | value if not matched), but we don't want anything in the "not matched" condition, so it is left blank.

    • @DimEarly
      @DimEarly  4 місяці тому +1

      Nice! I've come across the concept of conditional replacement for capture groups (although that doesn't seem to be working in the Excel implementation at the moment), but I didn't know you could do the same thing for calling back to an earlier capture group within a pattern - very nifty!
      I just tested it out, and confirmed it matches the original test cases, and does not match a number formatted as xxx) xxx-xxxx. It does still match the number part of (xxx xxx-xxx ignoring the bracket, but that's probably the right answer (since that could be a phone number appearing at the start of a longer parenthetical, for example).
      P.S.: How did I never realize that you have a YT channel with esports videos?? I just watched your Othello video - it was an impressive run!

    • @E_Pats
      @E_Pats 4 місяці тому

      @@DimEarly @DimEarly I've not had a chance to play with the regex functions in excel yet - I'm not sure which standard they follow and which do or don't work.
      Yeah, it will match those (xxx xxxx patterns - I guess specifying start/end with ^and $ would solve for that. There are some super complex patterns you can do to check for proper pairings of opening and closing parentheses, but it's been a long time since I've played with those! I remember once playing with a json parser using regex...!
      Haha thanks, I did quite a few last year - I'm hoping to get back to posting videos soon, I definitely need some more practice before October!

  • @salahaldeen7924
    @salahaldeen7924 4 місяці тому

    U r a treasure