Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. I love regular expressions

I love regular expressions

Scheduled Pinned Locked Moved The Lounge
designcomgraphicsiot
83 Posts 36 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Mircea NeacsuM Mircea Neacsu

    StarNamer@work wrote:

    "why can't they just put the letters in alphabetical order so they're easy to find?"

    A better question is "why are we so enslaved to tradition that we keep using a layout optimized for the Remington No 2 mechanical typewriter over 100 years ago?" And, please, don't get me started on the sexagesimal system used for time and degrees! :D

    Mircea

    P Offline
    P Offline
    Paul Sanders the other one
    wrote on last edited by
    #22

    Take my QWERTY keyboard away? Over my dead body!

    Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.

    1 Reply Last reply
    0
    • W Wizard of Sleeves

      Becoming fluent in regex is they first step to becoming a wizard. But a word of warning, never say them out loud, as there is a very good chance you will summon an evil demon (not daemon).

      Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.

      P Offline
      P Offline
      Paul Sanders the other one
      wrote on last edited by
      #23

      So you are fluent, then.

      Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.

      1 Reply Last reply
      0
      • K Kenneth Haugland

        Stay away from the vodka!!! Clinton Yeltsin disaster - YouTube[^] :laugh: I do like regular expressions too. But they often turn out to be very complicated to read and error-check.

        P Offline
        P Offline
        Paul Sanders the other one
        wrote on last edited by
        #24

        Too funny. Yeltsin was a good sport there.

        Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.

        1 Reply Last reply
        0
        • H honey the codewitch

          At least the non-backtracking subset. DFA regular expressions. - they are a compact way to describe a simple syntax - they are plain text and brief, easily communicatable and transferable - they are cross platform (at least DFA), running in most any engine - they are incredibly efficient (again, DFA) - they are versatile, able to do validation, tokenization, and matching as well That's probably why they will always be with us. They are maybe the perfect canonical execution of a Chomsky type 3 language. Sure, they can be really terse, but this is as much a strength as it is a weakness, because it facilitates some of the above. I know some people hate them, and I can understand that. But show me a better way.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          S Offline
          S Offline
          seismofish
          wrote on last edited by
          #25

          I'm absolutely with you on that. Also, with PCREs, the /x switch allows you to indent and comment to your heart's content, so you can write perfectly legible code, and there are on-line engines where you can drop your expression and your input and watch step by step while it does its magic. I'm not sure that I do a day's work without writing a regex and I know of no tool with anywhere near the power for parsing text. ~~~~~~~~ <°}}}>«<

          H B 2 Replies Last reply
          0
          • H honey the codewitch

            At least the non-backtracking subset. DFA regular expressions. - they are a compact way to describe a simple syntax - they are plain text and brief, easily communicatable and transferable - they are cross platform (at least DFA), running in most any engine - they are incredibly efficient (again, DFA) - they are versatile, able to do validation, tokenization, and matching as well That's probably why they will always be with us. They are maybe the perfect canonical execution of a Chomsky type 3 language. Sure, they can be really terse, but this is as much a strength as it is a weakness, because it facilitates some of the above. I know some people hate them, and I can understand that. But show me a better way.

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #26

            The problem with regular expressions, is that most of us use them once every couple of years and we have to relearn everything from scratch every time. For someone who's doing RE everyday, it's simple; I used to have a boss that was like that; we all went to her to write/debug our RE. (and we never document the RE in the code :rolleyes: )

            CI/CD = Continuous Impediment/Continuous Despair

            H J 2 Replies Last reply
            0
            • H honey the codewitch

              At least the non-backtracking subset. DFA regular expressions. - they are a compact way to describe a simple syntax - they are plain text and brief, easily communicatable and transferable - they are cross platform (at least DFA), running in most any engine - they are incredibly efficient (again, DFA) - they are versatile, able to do validation, tokenization, and matching as well That's probably why they will always be with us. They are maybe the perfect canonical execution of a Chomsky type 3 language. Sure, they can be really terse, but this is as much a strength as it is a weakness, because it facilitates some of the above. I know some people hate them, and I can understand that. But show me a better way.

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              C Offline
              C Offline
              Cpichols
              wrote on last edited by
              #27

              Since there are good regex interpreters online, I'm good with using them.

              1 Reply Last reply
              0
              • G giulicard

                Joking aside, more trivially I believe the term "regular" refers to the third level of Chomsky's hierarchy, which, precisely, is defined as Type3-Regular. DFA (Deterministic Finite Automaton) are FSA (Finite State Automaton).

                R Offline
                R Offline
                Ron Anders
                wrote on last edited by
                #28

                What the absolute ever. :-D

                1 Reply Last reply
                0
                • P Paul Sanders the other one

                  Love your sig 🤣🤣🤣

                  Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.

                  T Offline
                  T Offline
                  thewazz
                  wrote on last edited by
                  #29

                  Except there's a spelling mistake.

                  P 1 Reply Last reply
                  0
                  • H honey the codewitch

                    At least the non-backtracking subset. DFA regular expressions. - they are a compact way to describe a simple syntax - they are plain text and brief, easily communicatable and transferable - they are cross platform (at least DFA), running in most any engine - they are incredibly efficient (again, DFA) - they are versatile, able to do validation, tokenization, and matching as well That's probably why they will always be with us. They are maybe the perfect canonical execution of a Chomsky type 3 language. Sure, they can be really terse, but this is as much a strength as it is a weakness, because it facilitates some of the above. I know some people hate them, and I can understand that. But show me a better way.

                    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                    M Offline
                    M Offline
                    Mark Starr
                    wrote on last edited by
                    #30

                    Love how you post an opinion - always a valid one - and then (I assume) watch the conversation roll through. Bet you’re a gem at parties. I learned the basics of regular expressions many years ago when learning Perl. While I still use it on occasion for simple searches involving a specific character sequence, I don’t use it regularly (pun acknowledged) - aside from a few functions like email-check etc.

                    Time is the differentiation of eternity devised by man to measure the passage of human events. - Manly P. Hall Mark Just another cog in the wheel

                    H 1 Reply Last reply
                    0
                    • J jmaida

                      :) close cobol brings back a lot programming memories

                      "A little time, a little trouble, your better day" Badfinger

                      M Offline
                      M Offline
                      Matt Bond
                      wrote on last edited by
                      #31

                      Memories? I still use it.

                      Bond Keep all things as simple as possible, but no simpler. -said someone, somewhere

                      M 1 Reply Last reply
                      0
                      • M Mark Starr

                        Love how you post an opinion - always a valid one - and then (I assume) watch the conversation roll through. Bet you’re a gem at parties. I learned the basics of regular expressions many years ago when learning Perl. While I still use it on occasion for simple searches involving a specific character sequence, I don’t use it regularly (pun acknowledged) - aside from a few functions like email-check etc.

                        Time is the differentiation of eternity devised by man to measure the passage of human events. - Manly P. Hall Mark Just another cog in the wheel

                        H Offline
                        H Offline
                        honey the codewitch
                        wrote on last edited by
                        #32

                        It's because I slept. :) But yeah, I get bit overwhelmed when I get a lot of responses, so I kind of respond as I'm able.

                        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                        M 1 Reply Last reply
                        0
                        • T thewazz

                          Except there's a spelling mistake.

                          P Offline
                          P Offline
                          Paul Sanders the other one
                          wrote on last edited by
                          #33

                          Oh yes! Two, if you're a Yank :)

                          Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.

                          1 Reply Last reply
                          0
                          • J jmaida

                            how about natural language to regex translator? such a thing? i am checking.

                            "A little time, a little trouble, your better day" Badfinger

                            H Offline
                            H Offline
                            honey the codewitch
                            wrote on last edited by
                            #34

                            It seems like it would be difficult to describe a non-trivial match in human language. Though you might be able to feed a regex expression to ChatGPT and ask it what it matches - sort of the reverse of what you suggested.

                            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                            1 Reply Last reply
                            0
                            • J jmaida

                              how about natural language to regex translator? such a thing? i am checking.

                              "A little time, a little trouble, your better day" Badfinger

                              H Offline
                              H Offline
                              honey the codewitch
                              wrote on last edited by
                              #35

                              A long time ago I wrote a tool. The tool allowed you to multiply select portions of text and it would attempt to generate regexs that would only match the selected text It didn't work very well, at least my implementation but I think the idea has merit.

                              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                              K 1 Reply Last reply
                              0
                              • S seismofish

                                I'm absolutely with you on that. Also, with PCREs, the /x switch allows you to indent and comment to your heart's content, so you can write perfectly legible code, and there are on-line engines where you can drop your expression and your input and watch step by step while it does its magic. I'm not sure that I do a day's work without writing a regex and I know of no tool with anywhere near the power for parsing text. ~~~~~~~~ <°}}}>«<

                                H Offline
                                H Offline
                                honey the codewitch
                                wrote on last edited by
                                #36

                                seismofish wrote:

                                I know of no tool with anywhere near the power for parsing text.

                                Well, tokenizing text at least. :) I've written plenty of parsers, everything from LL(1) to GLR. GLR is the most powerful parsing algorithm I know of, allowing you to parse ambiguous grammars and return one tree for each possible interpretation. My parsers almost always use regex to tokenize, but they don't use it to parse. Instead, I take those tokens, and a Push Down Automaton and use that to generate trees. Sorry, not trying to be pedantic so much as continue to convo.

                                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                1 Reply Last reply
                                0
                                • M Maximilien

                                  The problem with regular expressions, is that most of us use them once every couple of years and we have to relearn everything from scratch every time. For someone who's doing RE everyday, it's simple; I used to have a boss that was like that; we all went to her to write/debug our RE. (and we never document the RE in the code :rolleyes: )

                                  CI/CD = Continuous Impediment/Continuous Despair

                                  H Offline
                                  H Offline
                                  honey the codewitch
                                  wrote on last edited by
                                  #37

                                  A modest proposal: Learn the DFA subset. Commit it to memory, and forget the rest. DFA is the non-backtracking subset of regular expressions () - capture and group [] - match char ranges * - match zero or more + - match one or more ? - match zero or one . - match any single character | - match a or b (a|b)

                                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                  J K 2 Replies Last reply
                                  0
                                  • H honey the codewitch

                                    At least the non-backtracking subset. DFA regular expressions. - they are a compact way to describe a simple syntax - they are plain text and brief, easily communicatable and transferable - they are cross platform (at least DFA), running in most any engine - they are incredibly efficient (again, DFA) - they are versatile, able to do validation, tokenization, and matching as well That's probably why they will always be with us. They are maybe the perfect canonical execution of a Chomsky type 3 language. Sure, they can be really terse, but this is as much a strength as it is a weakness, because it facilitates some of the above. I know some people hate them, and I can understand that. But show me a better way.

                                    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                    F Offline
                                    F Offline
                                    fatman45
                                    wrote on last edited by
                                    #38

                                    As an IoT person, you probably have done a lot of assembly language programming. I find that people who love regex tend to also like assembly (including myself). I find regex very elegant, and immensely powerful.

                                    Da Bomb

                                    H 1 Reply Last reply
                                    0
                                    • H honey the codewitch

                                      At least the non-backtracking subset. DFA regular expressions. - they are a compact way to describe a simple syntax - they are plain text and brief, easily communicatable and transferable - they are cross platform (at least DFA), running in most any engine - they are incredibly efficient (again, DFA) - they are versatile, able to do validation, tokenization, and matching as well That's probably why they will always be with us. They are maybe the perfect canonical execution of a Chomsky type 3 language. Sure, they can be really terse, but this is as much a strength as it is a weakness, because it facilitates some of the above. I know some people hate them, and I can understand that. But show me a better way.

                                      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                      D Offline
                                      D Offline
                                      Dweeberly
                                      wrote on last edited by
                                      #39

                                      My only reply is "Regexbuddy". Best tool I've found. Regex's indeed make some difficult things so easy ... and some easy things so difficult. Used in the right place they can be invaluable.

                                      1 Reply Last reply
                                      0
                                      • M Matt Bond

                                        Memories? I still use it.

                                        Bond Keep all things as simple as possible, but no simpler. -said someone, somewhere

                                        M Offline
                                        M Offline
                                        MarkTJohnson
                                        wrote on last edited by
                                        #40

                                        Richard Attenborough voice in his semi-whisper: Behold, the rare COBOL programmer in the wild, they used to roam in giant herds but are now solitary creatures. What will become of the banking ecosystem when the species becomes extinct?

                                        I’ve given up trying to be calm. However, I am open to feeling slightly less agitated. I’m begging you for the benefit of everyone, don’t be STUPID.

                                        K 1 Reply Last reply
                                        0
                                        • Mircea NeacsuM Mircea Neacsu

                                          StarNamer@work wrote:

                                          "why can't they just put the letters in alphabetical order so they're easy to find?"

                                          A better question is "why are we so enslaved to tradition that we keep using a layout optimized for the Remington No 2 mechanical typewriter over 100 years ago?" And, please, don't get me started on the sexagesimal system used for time and degrees! :D

                                          Mircea

                                          J Offline
                                          J Offline
                                          jschell
                                          wrote on last edited by
                                          #41

                                          Mircea Neacsu wrote:

                                          why are we so enslaved to tradition that we keep using a layout optimized for the Remington No 2 mechanical typewriter over 100 years ago

                                          I believe because, despite claims (and faked data), no alternative has been shown to actually be better. If I recall correct one of the magazines, either "Skeptical Inquirer" or "Skeptic" had at least one article in say the past 10 years that documented the history of that. Possible that there might be some that are as good as, but then that by itself is no reason to switch.

                                          H 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups