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. Most unusable technology award (my nomination - regular expressions)

Most unusable technology award (my nomination - regular expressions)

Scheduled Pinned Locked Moved The Lounge
csscomalgorithmshelptutorial
65 Posts 40 Posters 0 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.
  • A Offline
    A Offline
    Andrew Wiles
    wrote on last edited by
    #1

    Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

    www.it-workplace.com
    "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

    H S R M R 26 Replies Last reply
    0
    • A Andrew Wiles

      Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

      www.it-workplace.com
      "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      I find the carriage return key to be next to useless and I see that you agree. :-D

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

      A P S 3 Replies Last reply
      0
      • A Andrew Wiles

        Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

        www.it-workplace.com
        "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

        S Offline
        S Offline
        Slacker007
        wrote on last edited by
        #3

        Andrew Wiles wrote:

        Can anyone think of a less usable technology?

        .Net? J/K :rolleyes: I use regualar expressions, via Perl, all the time at work and it is a great tool. With that said, not all problems can or should be solved with regexes. Just looking at the example you have shown above, without really researching it, looks to me to be the work of an amateur. The rule of thumb with regualar expressions is that the longer and more complex they are, the more they are filled with bugs and bad matches. If your regex is that long, you are doing something wrong or you need to find another solution. my 2 cents.

        Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)

        N 1 Reply Last reply
        0
        • H Henry Minute

          I find the carriage return key to be next to useless and I see that you agree. :-D

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

          A Offline
          A Offline
          Andrew Wiles
          wrote on last edited by
          #4

          Re-formatted for your benefit (although I would argue that we could add text entry boxes for web applications as a nomination).

          www.it-workplace.com
          "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

          1 Reply Last reply
          0
          • A Andrew Wiles

            Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

            www.it-workplace.com
            "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

            R Offline
            R Offline
            Rage
            wrote on last edited by
            #5

            Andrew Wiles wrote:

            The sheer complexity of the expressions makes them virtually impossible to read and therefore understand

            It is at this point that you need the tool support. Better said, it is not because the thing seems complicated and unreadable that I won't use it if it solves my problem best.

            J 1 Reply Last reply
            0
            • A Andrew Wiles

              Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

              www.it-workplace.com
              "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

              M Offline
              M Offline
              Manfred Rudolf Bihy
              wrote on last edited by
              #6

              If the only tool you've got is a hammer, every problem looks like a nail! ;P Regular expressions are a very powerful tool when it comes to string matching, although as you've already stated the readability does suffer when you try to tackle complex matching operations. Still I think it is far easier than constructing a dedicated parser to accomplish the task even though there are lots of tools out there that help you in doing so: ANTLR, ProGrammar, Lex & Yacc (Bison) etc. I'm not sure though if reading a grammar is going to tickle your fanncy! :-D Cheers, Manfred

              "With sufficient thrust, pigs fly just fine."

              Ross Callon, The Twelve Networking Truths, RFC1925

              S A 2 Replies Last reply
              0
              • A Andrew Wiles

                Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

                www.it-workplace.com
                "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                R Offline
                R Offline
                Rhys Gravell
                wrote on last edited by
                #7

                A single Regex is really not sutable for UK post code, (incode and outcode), validation as there are post codes still in use that do not conform to current rules, (GIR 0AA as above). There are 6 valid post code formats plus one invalid one that's in use, I would probably validate each valid, (or invalid an in use), format individually with its own regex as what you've got there is pretty much unreadable... Either that or comment in a reference to the post code standards, (which can be found here...[^]), and apologise profusely to anyone that comes to that monstrosity after you :-)

                Rhys "Technological progress is like an axe in the hands of a pathological criminal" "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"

                D R 2 Replies Last reply
                0
                • A Andrew Wiles

                  Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

                  www.it-workplace.com
                  "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  Regexes are very usable technology - it's just that the syntax is somewhat arcane and it isn't easy to work out. Having said that, a tool like Expresso[^] can really help - it's free, and it examines, explains, generates and helps you create Regular expressions. They do get overused though: I would probably check a postcode against an online address checker rather than use a regex anyway - if only to save errors in data entry of the address.

                  Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  1 Reply Last reply
                  0
                  • A Andrew Wiles

                    Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

                    www.it-workplace.com
                    "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                    G Offline
                    G Offline
                    GuyThiebaut
                    wrote on last edited by
                    #9

                    I definitely agree with Slacker on this one. This is when a useful tool becomes an totally unhelpful. Yes regular expressions are very helpful when you can fit the pattern onto one line - any more than one line means another tool needs to be used.

                    “That which can be asserted without evidence, can be dismissed without evidence.”

                    ― Christopher Hitchens

                    1 Reply Last reply
                    0
                    • R Rhys Gravell

                      A single Regex is really not sutable for UK post code, (incode and outcode), validation as there are post codes still in use that do not conform to current rules, (GIR 0AA as above). There are 6 valid post code formats plus one invalid one that's in use, I would probably validate each valid, (or invalid an in use), format individually with its own regex as what you've got there is pretty much unreadable... Either that or comment in a reference to the post code standards, (which can be found here...[^]), and apologise profusely to anyone that comes to that monstrosity after you :-)

                      Rhys "Technological progress is like an axe in the hands of a pathological criminal" "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"

                      D Offline
                      D Offline
                      Dalek Dave
                      wrote on last edited by
                      #10

                      There are lists available for post code checking. But this is Useful for getting the format right.[^]

                      ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                      1 Reply Last reply
                      0
                      • A Andrew Wiles

                        Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

                        www.it-workplace.com
                        "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                        N Offline
                        N Offline
                        NormDroid
                        wrote on last edited by
                        #11

                        Looks readable to me, but there again I may just have an understanding of RE.

                        Software Kinetics Wear a hard hat it's under construction
                        Metro RSS

                        1 Reply Last reply
                        0
                        • S Slacker007

                          Andrew Wiles wrote:

                          Can anyone think of a less usable technology?

                          .Net? J/K :rolleyes: I use regualar expressions, via Perl, all the time at work and it is a great tool. With that said, not all problems can or should be solved with regexes. Just looking at the example you have shown above, without really researching it, looks to me to be the work of an amateur. The rule of thumb with regualar expressions is that the longer and more complex they are, the more they are filled with bugs and bad matches. If your regex is that long, you are doing something wrong or you need to find another solution. my 2 cents.

                          Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                          "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)

                          N Offline
                          N Offline
                          NormDroid
                          wrote on last edited by
                          #12

                          Yep REs are cool and should be used when needed, the RE looks unwieldly but understandable.

                          Software Kinetics Wear a hard hat it's under construction
                          Metro RSS

                          1 Reply Last reply
                          0
                          • M Manfred Rudolf Bihy

                            If the only tool you've got is a hammer, every problem looks like a nail! ;P Regular expressions are a very powerful tool when it comes to string matching, although as you've already stated the readability does suffer when you try to tackle complex matching operations. Still I think it is far easier than constructing a dedicated parser to accomplish the task even though there are lots of tools out there that help you in doing so: ANTLR, ProGrammar, Lex & Yacc (Bison) etc. I'm not sure though if reading a grammar is going to tickle your fanncy! :-D Cheers, Manfred

                            "With sufficient thrust, pigs fly just fine."

                            Ross Callon, The Twelve Networking Truths, RFC1925

                            S Offline
                            S Offline
                            Slacker007
                            wrote on last edited by
                            #13

                            Manfred R. Bihy wrote:

                            If the only tool you've got is a hammer, every problem looks like a nail!

                            I like that. :thumbsup:

                            Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                            "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)

                            W M 2 Replies Last reply
                            0
                            • A Andrew Wiles

                              Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

                              www.it-workplace.com
                              "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                              N Offline
                              N Offline
                              Nagy Vilmos
                              wrote on last edited by
                              #14

                              I think you are slightly over doing it. Isn't [A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2} enough?


                              Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                              N A 2 Replies Last reply
                              0
                              • A Andrew Wiles

                                Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

                                www.it-workplace.com
                                "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                                T Offline
                                T Offline
                                TorstenH
                                wrote on last edited by
                                #15

                                mobile phones with camera inside. Apple products. Fritzbox networking stuff. But really: String parsing is a pain in the a**, no matter how it's done. I avoid that as much as possible. and therefor I'm not forced to use regex. But when I do, I struggle my way through it like you did. Coffee and chocolate helps.

                                regards Torsten When I'm not working

                                N S 2 Replies Last reply
                                0
                                • N Nagy Vilmos

                                  I think you are slightly over doing it. Isn't [A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2} enough?


                                  Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                  N Offline
                                  N Offline
                                  NormDroid
                                  wrote on last edited by
                                  #16

                                  Laugh, that's far too concise :)

                                  Software Kinetics Wear a hard hat it's under construction
                                  Metro RSS

                                  1 Reply Last reply
                                  0
                                  • T TorstenH

                                    mobile phones with camera inside. Apple products. Fritzbox networking stuff. But really: String parsing is a pain in the a**, no matter how it's done. I avoid that as much as possible. and therefor I'm not forced to use regex. But when I do, I struggle my way through it like you did. Coffee and chocolate helps.

                                    regards Torsten When I'm not working

                                    N Offline
                                    N Offline
                                    NormDroid
                                    wrote on last edited by
                                    #17

                                    TorstenH. wrote:

                                    Apple products

                                    :thumbsup: Cheer from the lounge.

                                    Software Kinetics Wear a hard hat it's under construction
                                    Metro RSS

                                    1 Reply Last reply
                                    0
                                    • T TorstenH

                                      mobile phones with camera inside. Apple products. Fritzbox networking stuff. But really: String parsing is a pain in the a**, no matter how it's done. I avoid that as much as possible. and therefor I'm not forced to use regex. But when I do, I struggle my way through it like you did. Coffee and chocolate helps.

                                      regards Torsten When I'm not working

                                      S Offline
                                      S Offline
                                      Slacker007
                                      wrote on last edited by
                                      #18

                                      TorstenH. wrote:

                                      Coffee

                                      Nothing like a good cup of coffee to awaken the coding beast within. :)

                                      Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                      "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)

                                      1 Reply Last reply
                                      0
                                      • A Andrew Wiles

                                        Every now and then I need to solve a problem for which regular expressions looks like it is the "perfect" answer. Today that happens to be validating and extracting UK postal codes from addresses. BUT Every time I try to use regular expressions I find that no-one (especially me) has a clue how to use them and that all "posted" solutions can be demonstrated as flawed and therefore dangerous to use. The sheer complexity of the expressions makes them virtually impossible to read and therefore understand. I post the wikipedia solution to demonstrate my case (GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K [ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV] |YO|ZE)[1-9]?[0-9]|((E|N|NW|SE|SW|W)1|EC[1-4]|WC[12])[A-HJKMNPR-Y]|(SW|W)([2-9]|[1-9][0-9])|EC[1-9] [0-9]) [0-9][ABD-HJLNP-UW-Z]{2}) Can anyone think of a less usable technology?

                                        www.it-workplace.com
                                        "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                                        M Offline
                                        M Offline
                                        Minion no 5
                                        wrote on last edited by
                                        #19

                                        There are people who massage their ego by making the biggest and most labrythine RE possible. X|

                                        1 Reply Last reply
                                        0
                                        • N Nagy Vilmos

                                          I think you are slightly over doing it. Isn't [A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2} enough?


                                          Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                          A Offline
                                          A Offline
                                          Andrew Wiles
                                          wrote on last edited by
                                          #20

                                          Nearly, but doesn't cover the case where the user has not entered the space (i.e. 'LS1 9EL' vs 'LS19EL'). We also have some other occasional but common variations such as 'LS1_9EL' that we can try to parse for. My understanding is also that whilst this expression will validate the general format of the postcode there are specific exceptions that it does not cover. Unfortunately the task is not one of validating data at point of entry but matching data that has not been properly validated in the first place (>5m records), so refering to a web service such as the BING api is ruled out for performance reasons.

                                          www.it-workplace.com
                                          "If a man speaks in a forest where there is no woman to hear him, is he still wrong?"

                                          N G S M 4 Replies 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