Match the alphanumeric words(NOT NUMERIC-ONLY words) which have unique digits

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












7















Using regular expression, I want to select only the words which:



  • are alphanumeric

  • do not contain only numbers

  • do not contain only alphabets

  • have unique numbers(1 or more)

I am not really good with the regex but so far, I have tried [^ds]*(d+)(?!.*1) which takes me nowhere close to the desired output :(



Here are the input strings:



I would like abc123 to match but not 123.
ab12s should also match
Only number-words like 1234 should not match
Words containing same numbers like ab22s should not match
234 should not match
hel1lo2haha3hoho4
hel1lo2haha3hoho3


Expected Matches:



abc123
ab12s
hel1lo2haha3hoho4









share|improve this question




























    7















    Using regular expression, I want to select only the words which:



    • are alphanumeric

    • do not contain only numbers

    • do not contain only alphabets

    • have unique numbers(1 or more)

    I am not really good with the regex but so far, I have tried [^ds]*(d+)(?!.*1) which takes me nowhere close to the desired output :(



    Here are the input strings:



    I would like abc123 to match but not 123.
    ab12s should also match
    Only number-words like 1234 should not match
    Words containing same numbers like ab22s should not match
    234 should not match
    hel1lo2haha3hoho4
    hel1lo2haha3hoho3


    Expected Matches:



    abc123
    ab12s
    hel1lo2haha3hoho4









    share|improve this question


























      7












      7








      7


      1






      Using regular expression, I want to select only the words which:



      • are alphanumeric

      • do not contain only numbers

      • do not contain only alphabets

      • have unique numbers(1 or more)

      I am not really good with the regex but so far, I have tried [^ds]*(d+)(?!.*1) which takes me nowhere close to the desired output :(



      Here are the input strings:



      I would like abc123 to match but not 123.
      ab12s should also match
      Only number-words like 1234 should not match
      Words containing same numbers like ab22s should not match
      234 should not match
      hel1lo2haha3hoho4
      hel1lo2haha3hoho3


      Expected Matches:



      abc123
      ab12s
      hel1lo2haha3hoho4









      share|improve this question
















      Using regular expression, I want to select only the words which:



      • are alphanumeric

      • do not contain only numbers

      • do not contain only alphabets

      • have unique numbers(1 or more)

      I am not really good with the regex but so far, I have tried [^ds]*(d+)(?!.*1) which takes me nowhere close to the desired output :(



      Here are the input strings:



      I would like abc123 to match but not 123.
      ab12s should also match
      Only number-words like 1234 should not match
      Words containing same numbers like ab22s should not match
      234 should not match
      hel1lo2haha3hoho4
      hel1lo2haha3hoho3


      Expected Matches:



      abc123
      ab12s
      hel1lo2haha3hoho4






      javascript regex






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 2 at 6:58









      CertainPerformance

      88.4k154775




      88.4k154775










      asked Feb 2 at 6:44









      ManJoeyManJoey

      9916




      9916






















          4 Answers
          4






          active

          oldest

          votes


















          8














          You can use



          b(?=d*[a-z])(?=[a-z]*d)(?:[a-z]|(d)(?!w*1))+b


          https://regex101.com/r/TimjdW/3



          Anchor the start and end of the pattern at word boundaries with b, then:




          • (?=d*[a-z]) - Lookahead for an alphabetical character somewhere in the word


          • (?=[a-z]*d) - Lookahead for a digit somewhere in the word


          • (?:[a-z]|(d)(?!w*1))+ Repeatedly match either:


            • [a-z] - Any alphabetical character, or


            • (d)(?!w*1) - A digit which does not occur again in the same word






          share|improve this answer
































            3














            Here is a bit shorter & faster regex to make it happen since it doesn't assert negative lookahead for each character:



            /b(?=[a-z]*d)(?=d*[a-z])(?!w*(d)w*1)[a-zd]+b/ig


            RegEx Demo



            RegEx Details:




            • b: Word boundary


            • (?=[a-z]*d): Make sure we have at least a digit


            • (?=d*[a-z]): Make sure we have at least a letter


            • (?!w*(d)w*1): Make sure digits are not repeated anywhere in the word


            • [a-zd]+: Match 1+ alphanumericals


            • b: Word boundary





            share|improve this answer























            • @ManJoey: I believe the that selected regex will be slower for bigger strings

              – anubhava
              Feb 2 at 7:37











            • @anubhava, 1 in (?!w*(d)w*1) means (d) saved in memory's first buffer(like sed) kind of thing, sorry I am learning regex so thought to check with you on same once.

              – RavinderSingh13
              Feb 2 at 7:39







            • 1





              Yes that's correct. 1 is back-reference for captured group #1 i.e. (d)

              – anubhava
              Feb 2 at 7:41


















            2














            You could assert all the conditions using one negative lookahead:



            b(?![a-z]+b|d+b|w*(d)w*1)[a-zd]+b


            See live demo here



            The important parts are starting match from b and immediately looking for the conditions:



            • [a-z]+b Only alphabetic


            • d+b Only numeric


            • w*(d)w*1 Has a repeating digit






            share|improve this answer

























            • Thanks, good fix though not sure why one single negative lookahead with alternations shows more steps (as in my answer) than multiple assertions on regex101

              – anubhava
              Feb 2 at 7:07






            • 1





              @anubhava Yes, it depends on the input string. For example consider switching the first two lookaheads in your solution. You'll see it increases.

              – revo
              Feb 2 at 7:10



















            1














            You can use this



            b(?!w*(d)w*1)(?=(?:[a-z]+d+)|(?:d+[a-z]+))[a-z0-9]+b



            • b - Word boundary.


            • (?!w*(d)w*1) - Condition to check unique digits.


            • (?=(?:[a-z]+d+)|(?:d+[a-z]+)) - Condition to check alphanumeric words.


            • [a-z0-9]+ - Matches a to z and 0 to 9

            Demo






            share|improve this answer























            • Looking at all the answers here reminds me why I think regexes aren't the best way to solve this sort of problem… They're highly ingenious, but I'd hate to have to debug or maintain any of them!

              – gidds
              Feb 2 at 8:36






            • 1





              @gidds You can approach them the same way you approach any programming problem - break the problem down into logical groups, (re?)write and verify each group, and put it together into a single pattern. REs are a great concise way to match strings - they're extremely flexible and mostly language agnostic, which is a huge plus. As long as the pattern to debug has descriptive comments (like in the answers here), it shouldn't be hard at all for someone with a bit of experience with REs, IMO

              – CertainPerformance
              Feb 3 at 21:02










            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54490712%2fmatch-the-alphanumeric-wordsnot-numeric-only-words-which-have-unique-digits%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            8














            You can use



            b(?=d*[a-z])(?=[a-z]*d)(?:[a-z]|(d)(?!w*1))+b


            https://regex101.com/r/TimjdW/3



            Anchor the start and end of the pattern at word boundaries with b, then:




            • (?=d*[a-z]) - Lookahead for an alphabetical character somewhere in the word


            • (?=[a-z]*d) - Lookahead for a digit somewhere in the word


            • (?:[a-z]|(d)(?!w*1))+ Repeatedly match either:


              • [a-z] - Any alphabetical character, or


              • (d)(?!w*1) - A digit which does not occur again in the same word






            share|improve this answer





























              8














              You can use



              b(?=d*[a-z])(?=[a-z]*d)(?:[a-z]|(d)(?!w*1))+b


              https://regex101.com/r/TimjdW/3



              Anchor the start and end of the pattern at word boundaries with b, then:




              • (?=d*[a-z]) - Lookahead for an alphabetical character somewhere in the word


              • (?=[a-z]*d) - Lookahead for a digit somewhere in the word


              • (?:[a-z]|(d)(?!w*1))+ Repeatedly match either:


                • [a-z] - Any alphabetical character, or


                • (d)(?!w*1) - A digit which does not occur again in the same word






              share|improve this answer



























                8












                8








                8







                You can use



                b(?=d*[a-z])(?=[a-z]*d)(?:[a-z]|(d)(?!w*1))+b


                https://regex101.com/r/TimjdW/3



                Anchor the start and end of the pattern at word boundaries with b, then:




                • (?=d*[a-z]) - Lookahead for an alphabetical character somewhere in the word


                • (?=[a-z]*d) - Lookahead for a digit somewhere in the word


                • (?:[a-z]|(d)(?!w*1))+ Repeatedly match either:


                  • [a-z] - Any alphabetical character, or


                  • (d)(?!w*1) - A digit which does not occur again in the same word






                share|improve this answer















                You can use



                b(?=d*[a-z])(?=[a-z]*d)(?:[a-z]|(d)(?!w*1))+b


                https://regex101.com/r/TimjdW/3



                Anchor the start and end of the pattern at word boundaries with b, then:




                • (?=d*[a-z]) - Lookahead for an alphabetical character somewhere in the word


                • (?=[a-z]*d) - Lookahead for a digit somewhere in the word


                • (?:[a-z]|(d)(?!w*1))+ Repeatedly match either:


                  • [a-z] - Any alphabetical character, or


                  • (d)(?!w*1) - A digit which does not occur again in the same word







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 2 at 6:56

























                answered Feb 2 at 6:50









                CertainPerformanceCertainPerformance

                88.4k154775




                88.4k154775























                    3














                    Here is a bit shorter & faster regex to make it happen since it doesn't assert negative lookahead for each character:



                    /b(?=[a-z]*d)(?=d*[a-z])(?!w*(d)w*1)[a-zd]+b/ig


                    RegEx Demo



                    RegEx Details:




                    • b: Word boundary


                    • (?=[a-z]*d): Make sure we have at least a digit


                    • (?=d*[a-z]): Make sure we have at least a letter


                    • (?!w*(d)w*1): Make sure digits are not repeated anywhere in the word


                    • [a-zd]+: Match 1+ alphanumericals


                    • b: Word boundary





                    share|improve this answer























                    • @ManJoey: I believe the that selected regex will be slower for bigger strings

                      – anubhava
                      Feb 2 at 7:37











                    • @anubhava, 1 in (?!w*(d)w*1) means (d) saved in memory's first buffer(like sed) kind of thing, sorry I am learning regex so thought to check with you on same once.

                      – RavinderSingh13
                      Feb 2 at 7:39







                    • 1





                      Yes that's correct. 1 is back-reference for captured group #1 i.e. (d)

                      – anubhava
                      Feb 2 at 7:41















                    3














                    Here is a bit shorter & faster regex to make it happen since it doesn't assert negative lookahead for each character:



                    /b(?=[a-z]*d)(?=d*[a-z])(?!w*(d)w*1)[a-zd]+b/ig


                    RegEx Demo



                    RegEx Details:




                    • b: Word boundary


                    • (?=[a-z]*d): Make sure we have at least a digit


                    • (?=d*[a-z]): Make sure we have at least a letter


                    • (?!w*(d)w*1): Make sure digits are not repeated anywhere in the word


                    • [a-zd]+: Match 1+ alphanumericals


                    • b: Word boundary





                    share|improve this answer























                    • @ManJoey: I believe the that selected regex will be slower for bigger strings

                      – anubhava
                      Feb 2 at 7:37











                    • @anubhava, 1 in (?!w*(d)w*1) means (d) saved in memory's first buffer(like sed) kind of thing, sorry I am learning regex so thought to check with you on same once.

                      – RavinderSingh13
                      Feb 2 at 7:39







                    • 1





                      Yes that's correct. 1 is back-reference for captured group #1 i.e. (d)

                      – anubhava
                      Feb 2 at 7:41













                    3












                    3








                    3







                    Here is a bit shorter & faster regex to make it happen since it doesn't assert negative lookahead for each character:



                    /b(?=[a-z]*d)(?=d*[a-z])(?!w*(d)w*1)[a-zd]+b/ig


                    RegEx Demo



                    RegEx Details:




                    • b: Word boundary


                    • (?=[a-z]*d): Make sure we have at least a digit


                    • (?=d*[a-z]): Make sure we have at least a letter


                    • (?!w*(d)w*1): Make sure digits are not repeated anywhere in the word


                    • [a-zd]+: Match 1+ alphanumericals


                    • b: Word boundary





                    share|improve this answer













                    Here is a bit shorter & faster regex to make it happen since it doesn't assert negative lookahead for each character:



                    /b(?=[a-z]*d)(?=d*[a-z])(?!w*(d)w*1)[a-zd]+b/ig


                    RegEx Demo



                    RegEx Details:




                    • b: Word boundary


                    • (?=[a-z]*d): Make sure we have at least a digit


                    • (?=d*[a-z]): Make sure we have at least a letter


                    • (?!w*(d)w*1): Make sure digits are not repeated anywhere in the word


                    • [a-zd]+: Match 1+ alphanumericals


                    • b: Word boundary






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 2 at 7:00









                    anubhavaanubhava

                    528k46327403




                    528k46327403












                    • @ManJoey: I believe the that selected regex will be slower for bigger strings

                      – anubhava
                      Feb 2 at 7:37











                    • @anubhava, 1 in (?!w*(d)w*1) means (d) saved in memory's first buffer(like sed) kind of thing, sorry I am learning regex so thought to check with you on same once.

                      – RavinderSingh13
                      Feb 2 at 7:39







                    • 1





                      Yes that's correct. 1 is back-reference for captured group #1 i.e. (d)

                      – anubhava
                      Feb 2 at 7:41

















                    • @ManJoey: I believe the that selected regex will be slower for bigger strings

                      – anubhava
                      Feb 2 at 7:37











                    • @anubhava, 1 in (?!w*(d)w*1) means (d) saved in memory's first buffer(like sed) kind of thing, sorry I am learning regex so thought to check with you on same once.

                      – RavinderSingh13
                      Feb 2 at 7:39







                    • 1





                      Yes that's correct. 1 is back-reference for captured group #1 i.e. (d)

                      – anubhava
                      Feb 2 at 7:41
















                    @ManJoey: I believe the that selected regex will be slower for bigger strings

                    – anubhava
                    Feb 2 at 7:37





                    @ManJoey: I believe the that selected regex will be slower for bigger strings

                    – anubhava
                    Feb 2 at 7:37













                    @anubhava, 1 in (?!w*(d)w*1) means (d) saved in memory's first buffer(like sed) kind of thing, sorry I am learning regex so thought to check with you on same once.

                    – RavinderSingh13
                    Feb 2 at 7:39






                    @anubhava, 1 in (?!w*(d)w*1) means (d) saved in memory's first buffer(like sed) kind of thing, sorry I am learning regex so thought to check with you on same once.

                    – RavinderSingh13
                    Feb 2 at 7:39





                    1




                    1





                    Yes that's correct. 1 is back-reference for captured group #1 i.e. (d)

                    – anubhava
                    Feb 2 at 7:41





                    Yes that's correct. 1 is back-reference for captured group #1 i.e. (d)

                    – anubhava
                    Feb 2 at 7:41











                    2














                    You could assert all the conditions using one negative lookahead:



                    b(?![a-z]+b|d+b|w*(d)w*1)[a-zd]+b


                    See live demo here



                    The important parts are starting match from b and immediately looking for the conditions:



                    • [a-z]+b Only alphabetic


                    • d+b Only numeric


                    • w*(d)w*1 Has a repeating digit






                    share|improve this answer

























                    • Thanks, good fix though not sure why one single negative lookahead with alternations shows more steps (as in my answer) than multiple assertions on regex101

                      – anubhava
                      Feb 2 at 7:07






                    • 1





                      @anubhava Yes, it depends on the input string. For example consider switching the first two lookaheads in your solution. You'll see it increases.

                      – revo
                      Feb 2 at 7:10
















                    2














                    You could assert all the conditions using one negative lookahead:



                    b(?![a-z]+b|d+b|w*(d)w*1)[a-zd]+b


                    See live demo here



                    The important parts are starting match from b and immediately looking for the conditions:



                    • [a-z]+b Only alphabetic


                    • d+b Only numeric


                    • w*(d)w*1 Has a repeating digit






                    share|improve this answer

























                    • Thanks, good fix though not sure why one single negative lookahead with alternations shows more steps (as in my answer) than multiple assertions on regex101

                      – anubhava
                      Feb 2 at 7:07






                    • 1





                      @anubhava Yes, it depends on the input string. For example consider switching the first two lookaheads in your solution. You'll see it increases.

                      – revo
                      Feb 2 at 7:10














                    2












                    2








                    2







                    You could assert all the conditions using one negative lookahead:



                    b(?![a-z]+b|d+b|w*(d)w*1)[a-zd]+b


                    See live demo here



                    The important parts are starting match from b and immediately looking for the conditions:



                    • [a-z]+b Only alphabetic


                    • d+b Only numeric


                    • w*(d)w*1 Has a repeating digit






                    share|improve this answer















                    You could assert all the conditions using one negative lookahead:



                    b(?![a-z]+b|d+b|w*(d)w*1)[a-zd]+b


                    See live demo here



                    The important parts are starting match from b and immediately looking for the conditions:



                    • [a-z]+b Only alphabetic


                    • d+b Only numeric


                    • w*(d)w*1 Has a repeating digit







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Feb 2 at 7:04

























                    answered Feb 2 at 7:00









                    revorevo

                    33.2k134984




                    33.2k134984












                    • Thanks, good fix though not sure why one single negative lookahead with alternations shows more steps (as in my answer) than multiple assertions on regex101

                      – anubhava
                      Feb 2 at 7:07






                    • 1





                      @anubhava Yes, it depends on the input string. For example consider switching the first two lookaheads in your solution. You'll see it increases.

                      – revo
                      Feb 2 at 7:10


















                    • Thanks, good fix though not sure why one single negative lookahead with alternations shows more steps (as in my answer) than multiple assertions on regex101

                      – anubhava
                      Feb 2 at 7:07






                    • 1





                      @anubhava Yes, it depends on the input string. For example consider switching the first two lookaheads in your solution. You'll see it increases.

                      – revo
                      Feb 2 at 7:10

















                    Thanks, good fix though not sure why one single negative lookahead with alternations shows more steps (as in my answer) than multiple assertions on regex101

                    – anubhava
                    Feb 2 at 7:07





                    Thanks, good fix though not sure why one single negative lookahead with alternations shows more steps (as in my answer) than multiple assertions on regex101

                    – anubhava
                    Feb 2 at 7:07




                    1




                    1





                    @anubhava Yes, it depends on the input string. For example consider switching the first two lookaheads in your solution. You'll see it increases.

                    – revo
                    Feb 2 at 7:10






                    @anubhava Yes, it depends on the input string. For example consider switching the first two lookaheads in your solution. You'll see it increases.

                    – revo
                    Feb 2 at 7:10












                    1














                    You can use this



                    b(?!w*(d)w*1)(?=(?:[a-z]+d+)|(?:d+[a-z]+))[a-z0-9]+b



                    • b - Word boundary.


                    • (?!w*(d)w*1) - Condition to check unique digits.


                    • (?=(?:[a-z]+d+)|(?:d+[a-z]+)) - Condition to check alphanumeric words.


                    • [a-z0-9]+ - Matches a to z and 0 to 9

                    Demo






                    share|improve this answer























                    • Looking at all the answers here reminds me why I think regexes aren't the best way to solve this sort of problem… They're highly ingenious, but I'd hate to have to debug or maintain any of them!

                      – gidds
                      Feb 2 at 8:36






                    • 1





                      @gidds You can approach them the same way you approach any programming problem - break the problem down into logical groups, (re?)write and verify each group, and put it together into a single pattern. REs are a great concise way to match strings - they're extremely flexible and mostly language agnostic, which is a huge plus. As long as the pattern to debug has descriptive comments (like in the answers here), it shouldn't be hard at all for someone with a bit of experience with REs, IMO

                      – CertainPerformance
                      Feb 3 at 21:02















                    1














                    You can use this



                    b(?!w*(d)w*1)(?=(?:[a-z]+d+)|(?:d+[a-z]+))[a-z0-9]+b



                    • b - Word boundary.


                    • (?!w*(d)w*1) - Condition to check unique digits.


                    • (?=(?:[a-z]+d+)|(?:d+[a-z]+)) - Condition to check alphanumeric words.


                    • [a-z0-9]+ - Matches a to z and 0 to 9

                    Demo






                    share|improve this answer























                    • Looking at all the answers here reminds me why I think regexes aren't the best way to solve this sort of problem… They're highly ingenious, but I'd hate to have to debug or maintain any of them!

                      – gidds
                      Feb 2 at 8:36






                    • 1





                      @gidds You can approach them the same way you approach any programming problem - break the problem down into logical groups, (re?)write and verify each group, and put it together into a single pattern. REs are a great concise way to match strings - they're extremely flexible and mostly language agnostic, which is a huge plus. As long as the pattern to debug has descriptive comments (like in the answers here), it shouldn't be hard at all for someone with a bit of experience with REs, IMO

                      – CertainPerformance
                      Feb 3 at 21:02













                    1












                    1








                    1







                    You can use this



                    b(?!w*(d)w*1)(?=(?:[a-z]+d+)|(?:d+[a-z]+))[a-z0-9]+b



                    • b - Word boundary.


                    • (?!w*(d)w*1) - Condition to check unique digits.


                    • (?=(?:[a-z]+d+)|(?:d+[a-z]+)) - Condition to check alphanumeric words.


                    • [a-z0-9]+ - Matches a to z and 0 to 9

                    Demo






                    share|improve this answer













                    You can use this



                    b(?!w*(d)w*1)(?=(?:[a-z]+d+)|(?:d+[a-z]+))[a-z0-9]+b



                    • b - Word boundary.


                    • (?!w*(d)w*1) - Condition to check unique digits.


                    • (?=(?:[a-z]+d+)|(?:d+[a-z]+)) - Condition to check alphanumeric words.


                    • [a-z0-9]+ - Matches a to z and 0 to 9

                    Demo







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 2 at 7:04









                    Code ManiacCode Maniac

                    7,1221426




                    7,1221426












                    • Looking at all the answers here reminds me why I think regexes aren't the best way to solve this sort of problem… They're highly ingenious, but I'd hate to have to debug or maintain any of them!

                      – gidds
                      Feb 2 at 8:36






                    • 1





                      @gidds You can approach them the same way you approach any programming problem - break the problem down into logical groups, (re?)write and verify each group, and put it together into a single pattern. REs are a great concise way to match strings - they're extremely flexible and mostly language agnostic, which is a huge plus. As long as the pattern to debug has descriptive comments (like in the answers here), it shouldn't be hard at all for someone with a bit of experience with REs, IMO

                      – CertainPerformance
                      Feb 3 at 21:02

















                    • Looking at all the answers here reminds me why I think regexes aren't the best way to solve this sort of problem… They're highly ingenious, but I'd hate to have to debug or maintain any of them!

                      – gidds
                      Feb 2 at 8:36






                    • 1





                      @gidds You can approach them the same way you approach any programming problem - break the problem down into logical groups, (re?)write and verify each group, and put it together into a single pattern. REs are a great concise way to match strings - they're extremely flexible and mostly language agnostic, which is a huge plus. As long as the pattern to debug has descriptive comments (like in the answers here), it shouldn't be hard at all for someone with a bit of experience with REs, IMO

                      – CertainPerformance
                      Feb 3 at 21:02
















                    Looking at all the answers here reminds me why I think regexes aren't the best way to solve this sort of problem… They're highly ingenious, but I'd hate to have to debug or maintain any of them!

                    – gidds
                    Feb 2 at 8:36





                    Looking at all the answers here reminds me why I think regexes aren't the best way to solve this sort of problem… They're highly ingenious, but I'd hate to have to debug or maintain any of them!

                    – gidds
                    Feb 2 at 8:36




                    1




                    1





                    @gidds You can approach them the same way you approach any programming problem - break the problem down into logical groups, (re?)write and verify each group, and put it together into a single pattern. REs are a great concise way to match strings - they're extremely flexible and mostly language agnostic, which is a huge plus. As long as the pattern to debug has descriptive comments (like in the answers here), it shouldn't be hard at all for someone with a bit of experience with REs, IMO

                    – CertainPerformance
                    Feb 3 at 21:02





                    @gidds You can approach them the same way you approach any programming problem - break the problem down into logical groups, (re?)write and verify each group, and put it together into a single pattern. REs are a great concise way to match strings - they're extremely flexible and mostly language agnostic, which is a huge plus. As long as the pattern to debug has descriptive comments (like in the answers here), it shouldn't be hard at all for someone with a bit of experience with REs, IMO

                    – CertainPerformance
                    Feb 3 at 21:02

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54490712%2fmatch-the-alphanumeric-wordsnot-numeric-only-words-which-have-unique-digits%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay