awk: error : tent of

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











up vote
3
down vote

favorite












I use the following regex to find email addresses:



echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'


But it returns the error:



 awk: cmd. line:1: error : tent of 






share|improve this question

























    up vote
    3
    down vote

    favorite












    I use the following regex to find email addresses:



    echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'


    But it returns the error:



     awk: cmd. line:1: error : tent of 






    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I use the following regex to find email addresses:



      echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'


      But it returns the error:



       awk: cmd. line:1: error : tent of 






      share|improve this question













      I use the following regex to find email addresses:



      echo "name@server.com" | awk '/^([a-zA-Z0-9_-.+]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]2,5)$/ print $0'


      But it returns the error:



       awk: cmd. line:1: error : tent of 








      share|improve this question












      share|improve this question




      share|improve this question








      edited Jun 6 at 10:31









      Jeff Schaller

      30.9k846105




      30.9k846105









      asked Jun 6 at 9:53









      sci9

      1609




      1609




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          Short version, use this:



          $ echo "name@server.com" | 
          > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'



          Assuming the actual error message is something like:



          awk: cmd. line:1: error: Invalid range end: …


          Then, there are 4 issues in your line:




          1. The dash (-) means "character range" not an explicit dash.



            The reason for the error message is that the two characters surrounding the dash (-) inside the character range (_ and .) are not in (ASCII) order. The character range .-_ raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot . and an underscore _), but to match an explicit dash (-).



            To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either [-…], […-]. Or, discouraged, escape it -. That is, both of these work:



            [-a-zA-Z0-9_.+]
            [a-zA-Z0-9_.+-]


            But no, a backslash is not a general solution to make a dash explicit. Try:



            $ echo 'ab-cd' | grep -Eo '[a-c]+'
            ab
            c


            The grep regex (even if extended: -E) does not match the dash.




          2. The + is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:



            ^([-a-zA-Z0-9_.+]+)@



          3. A dot . is an special character that "match any character except newline".

            As such, you need to either escape it . or use a "bracket expression" [.] to explicitly match a dot character, use this:



            ^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).



          4. And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:



            ([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$


          But you are probably using GNU awk, and the correct syntax should then be:



          $ echo "name@server.com" | 
          > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'





          share|improve this answer




























            up vote
            2
            down vote













            Answer:



            echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
            name@server.com


            Explanation:
            The character - is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.



            Further info:
            Check your regexes on this useful website when in doubt.




            As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: . represents any character, and you should escape it if you want it to mean a literal dot .



            Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to + in the first character set, and I have to thank Isaac again for spotting this!



            One more thing that is beyond me is why you would use all those round brackets ().



            Apart from correcting the use of - and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.






            share|improve this answer























            • Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
              – Kusalananda
              Jun 6 at 15:27










            • The dot (.) should be escaped. The plus (+) needs no escaping.
              – Isaac
              Jun 6 at 21:00










            • @Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
              – Isaac
              Jun 6 at 21:27











            • @Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
              – simlev
              Jun 8 at 9:10

















            up vote
            1
            down vote













            The hyphen - is special character in character class (Bracket Expression) which specifying the character range. If you want add literal - into your character class you will need to either escape it or move it to the end or beginning (after the ^, if any) of your character class.



            [a-z-]
            [-a-z]
            [a-z-A-Z]



            7.[...]



            The < hyphen-minus > character shall be treated as itself if it occurs
            first (after an initial ^, if any) or last in the list, or as an
            ending range point in a range expression. As examples, the expressions
            [-ac] and [ac-] are equivalent and match any of the characters
            'a', 'c', or '-'; [^-ac] and [^ac-] are equivalent and match any
            characters except 'a', 'c', or '-'; [...]



            If a bracket expression specifies both '-' and ']', the ']' shall be
            placed first (after the '^', if any) and the '-' last within the
            bracket expression.







            share|improve this answer























            • It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
              – Isaac
              Jun 6 at 21:06

















            up vote
            0
            down vote













            Which version of awk are you using?



            This command does not error when I use GNU awk, although it produces no output.



            Using solaris awk it produces this error:



            awk: syntax error near line 1
            awk: bailing out near line 1


            Reading through your regex, it's never going to match an email address...






            share|improve this answer























            • I use GNU Awk 4.1.3 under ubuntu 16.04.
              – sci9
              Jun 6 at 10:01










            • "Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
              – sci9
              Jun 6 at 10:03










            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448145%2fawk-error-tent-of%23new-answer', 'question_page');

            );

            Post as a guest






























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote



            accepted










            Short version, use this:



            $ echo "name@server.com" | 
            > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'



            Assuming the actual error message is something like:



            awk: cmd. line:1: error: Invalid range end: …


            Then, there are 4 issues in your line:




            1. The dash (-) means "character range" not an explicit dash.



              The reason for the error message is that the two characters surrounding the dash (-) inside the character range (_ and .) are not in (ASCII) order. The character range .-_ raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot . and an underscore _), but to match an explicit dash (-).



              To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either [-…], […-]. Or, discouraged, escape it -. That is, both of these work:



              [-a-zA-Z0-9_.+]
              [a-zA-Z0-9_.+-]


              But no, a backslash is not a general solution to make a dash explicit. Try:



              $ echo 'ab-cd' | grep -Eo '[a-c]+'
              ab
              c


              The grep regex (even if extended: -E) does not match the dash.




            2. The + is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:



              ^([-a-zA-Z0-9_.+]+)@



            3. A dot . is an special character that "match any character except newline".

              As such, you need to either escape it . or use a "bracket expression" [.] to explicitly match a dot character, use this:



              ^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).



            4. And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:



              ([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$


            But you are probably using GNU awk, and the correct syntax should then be:



            $ echo "name@server.com" | 
            > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'





            share|improve this answer

























              up vote
              2
              down vote



              accepted










              Short version, use this:



              $ echo "name@server.com" | 
              > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'



              Assuming the actual error message is something like:



              awk: cmd. line:1: error: Invalid range end: …


              Then, there are 4 issues in your line:




              1. The dash (-) means "character range" not an explicit dash.



                The reason for the error message is that the two characters surrounding the dash (-) inside the character range (_ and .) are not in (ASCII) order. The character range .-_ raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot . and an underscore _), but to match an explicit dash (-).



                To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either [-…], […-]. Or, discouraged, escape it -. That is, both of these work:



                [-a-zA-Z0-9_.+]
                [a-zA-Z0-9_.+-]


                But no, a backslash is not a general solution to make a dash explicit. Try:



                $ echo 'ab-cd' | grep -Eo '[a-c]+'
                ab
                c


                The grep regex (even if extended: -E) does not match the dash.




              2. The + is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:



                ^([-a-zA-Z0-9_.+]+)@



              3. A dot . is an special character that "match any character except newline".

                As such, you need to either escape it . or use a "bracket expression" [.] to explicitly match a dot character, use this:



                ^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).



              4. And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:



                ([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$


              But you are probably using GNU awk, and the correct syntax should then be:



              $ echo "name@server.com" | 
              > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'





              share|improve this answer























                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                Short version, use this:



                $ echo "name@server.com" | 
                > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'



                Assuming the actual error message is something like:



                awk: cmd. line:1: error: Invalid range end: …


                Then, there are 4 issues in your line:




                1. The dash (-) means "character range" not an explicit dash.



                  The reason for the error message is that the two characters surrounding the dash (-) inside the character range (_ and .) are not in (ASCII) order. The character range .-_ raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot . and an underscore _), but to match an explicit dash (-).



                  To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either [-…], […-]. Or, discouraged, escape it -. That is, both of these work:



                  [-a-zA-Z0-9_.+]
                  [a-zA-Z0-9_.+-]


                  But no, a backslash is not a general solution to make a dash explicit. Try:



                  $ echo 'ab-cd' | grep -Eo '[a-c]+'
                  ab
                  c


                  The grep regex (even if extended: -E) does not match the dash.




                2. The + is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:



                  ^([-a-zA-Z0-9_.+]+)@



                3. A dot . is an special character that "match any character except newline".

                  As such, you need to either escape it . or use a "bracket expression" [.] to explicitly match a dot character, use this:



                  ^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).



                4. And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:



                  ([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$


                But you are probably using GNU awk, and the correct syntax should then be:



                $ echo "name@server.com" | 
                > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'





                share|improve this answer













                Short version, use this:



                $ echo "name@server.com" | 
                > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'



                Assuming the actual error message is something like:



                awk: cmd. line:1: error: Invalid range end: …


                Then, there are 4 issues in your line:




                1. The dash (-) means "character range" not an explicit dash.



                  The reason for the error message is that the two characters surrounding the dash (-) inside the character range (_ and .) are not in (ASCII) order. The character range .-_ raise no error. But I am certain that you do not mean to say "character range" (all characters between a dot . and an underscore _), but to match an explicit dash (-).



                  To match an explicit dash inside a "bracket expression" you need to make it the first or the last character of the range. Either [-…], […-]. Or, discouraged, escape it -. That is, both of these work:



                  [-a-zA-Z0-9_.+]
                  [a-zA-Z0-9_.+-]


                  But no, a backslash is not a general solution to make a dash explicit. Try:



                  $ echo 'ab-cd' | grep -Eo '[a-c]+'
                  ab
                  c


                  The grep regex (even if extended: -E) does not match the dash.




                2. The + is not special inside a "bracket expression", thus, it needs no escaping (and escaping inside "bracket expressions" is a bad habit). Use this:



                  ^([-a-zA-Z0-9_.+]+)@



                3. A dot . is an special character that "match any character except newline".

                  As such, you need to either escape it . or use a "bracket expression" [.] to explicitly match a dot character, use this:



                  ^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).



                4. And, finally, the "interval expression" is an extension over historical awk implementations, it may not work in all awk's. This is usually "not a problem", but if it is, you will need to use:



                  ([a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?[a-zA-Z]?)$


                But you are probably using GNU awk, and the correct syntax should then be:



                $ echo "name@server.com" | 
                > gawk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/'






                share|improve this answer













                share|improve this answer



                share|improve this answer











                answered Jun 6 at 20:56









                Isaac

                6,3041632




                6,3041632






















                    up vote
                    2
                    down vote













                    Answer:



                    echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
                    name@server.com


                    Explanation:
                    The character - is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.



                    Further info:
                    Check your regexes on this useful website when in doubt.




                    As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: . represents any character, and you should escape it if you want it to mean a literal dot .



                    Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to + in the first character set, and I have to thank Isaac again for spotting this!



                    One more thing that is beyond me is why you would use all those round brackets ().



                    Apart from correcting the use of - and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.






                    share|improve this answer























                    • Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
                      – Kusalananda
                      Jun 6 at 15:27










                    • The dot (.) should be escaped. The plus (+) needs no escaping.
                      – Isaac
                      Jun 6 at 21:00










                    • @Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
                      – Isaac
                      Jun 6 at 21:27











                    • @Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
                      – simlev
                      Jun 8 at 9:10














                    up vote
                    2
                    down vote













                    Answer:



                    echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
                    name@server.com


                    Explanation:
                    The character - is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.



                    Further info:
                    Check your regexes on this useful website when in doubt.




                    As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: . represents any character, and you should escape it if you want it to mean a literal dot .



                    Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to + in the first character set, and I have to thank Isaac again for spotting this!



                    One more thing that is beyond me is why you would use all those round brackets ().



                    Apart from correcting the use of - and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.






                    share|improve this answer























                    • Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
                      – Kusalananda
                      Jun 6 at 15:27










                    • The dot (.) should be escaped. The plus (+) needs no escaping.
                      – Isaac
                      Jun 6 at 21:00










                    • @Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
                      – Isaac
                      Jun 6 at 21:27











                    • @Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
                      – simlev
                      Jun 8 at 9:10












                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    Answer:



                    echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
                    name@server.com


                    Explanation:
                    The character - is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.



                    Further info:
                    Check your regexes on this useful website when in doubt.




                    As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: . represents any character, and you should escape it if you want it to mean a literal dot .



                    Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to + in the first character set, and I have to thank Isaac again for spotting this!



                    One more thing that is beyond me is why you would use all those round brackets ().



                    Apart from correcting the use of - and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.






                    share|improve this answer















                    Answer:



                    echo "name@server.com" | awk '/^([-a-zA-Z0-9_.+]+)@([-a-zA-Z0-9_.]+).([a-zA-Z]2,5)$/ print $0'
                    name@server.com


                    Explanation:
                    The character - is ambiguous in the position where you put it, since it could represent an interval. Moving it to the beginning of the regexp, or escaping it, works just fine.



                    Further info:
                    Check your regexes on this useful website when in doubt.




                    As correctly pointed out by Isaac, the last dot in the expression does not do what you probably think it does: . represents any character, and you should escape it if you want it to mean a literal dot .



                    Further optimizations include not escaping characters inside brackets since it is unnecessary. I'm pointing to + in the first character set, and I have to thank Isaac again for spotting this!



                    One more thing that is beyond me is why you would use all those round brackets ().



                    Apart from correcting the use of - and suggesting a few minor improvements, the underlying theme here is the vastly discussed opportunity of employing regular expressions to validate email addresses. Correctly matching any email address is a tough task that requires a far more complex expression than one would initially imagine. A reasonable take, often found on this and similar forums is to use the simplest regex that is expectedly going to work with your dataset.







                    share|improve this answer















                    share|improve this answer



                    share|improve this answer








                    edited Jun 7 at 10:16


























                    answered Jun 6 at 10:18









                    simlev

                    47019




                    47019











                    • Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
                      – Kusalananda
                      Jun 6 at 15:27










                    • The dot (.) should be escaped. The plus (+) needs no escaping.
                      – Isaac
                      Jun 6 at 21:00










                    • @Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
                      – Isaac
                      Jun 6 at 21:27











                    • @Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
                      – simlev
                      Jun 8 at 9:10
















                    • Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
                      – Kusalananda
                      Jun 6 at 15:27










                    • The dot (.) should be escaped. The plus (+) needs no escaping.
                      – Isaac
                      Jun 6 at 21:00










                    • @Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
                      – Isaac
                      Jun 6 at 21:27











                    • @Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
                      – simlev
                      Jun 8 at 9:10















                    Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
                    – Kusalananda
                    Jun 6 at 15:27




                    Note that the website that you link to does not provide a way of testing standard POSIX regular expressions, as far as I can see.
                    – Kusalananda
                    Jun 6 at 15:27












                    The dot (.) should be escaped. The plus (+) needs no escaping.
                    – Isaac
                    Jun 6 at 21:00




                    The dot (.) should be escaped. The plus (+) needs no escaping.
                    – Isaac
                    Jun 6 at 21:00












                    @Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
                    – Isaac
                    Jun 6 at 21:27





                    @Kusalananda Use this link. It is not very good, but at least both BRE and ERE are named there.
                    – Isaac
                    Jun 6 at 21:27













                    @Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
                    – simlev
                    Jun 8 at 9:10




                    @Kusalananda good point, I'm spoiled by PCRE and would recommend using tools that support them.
                    – simlev
                    Jun 8 at 9:10










                    up vote
                    1
                    down vote













                    The hyphen - is special character in character class (Bracket Expression) which specifying the character range. If you want add literal - into your character class you will need to either escape it or move it to the end or beginning (after the ^, if any) of your character class.



                    [a-z-]
                    [-a-z]
                    [a-z-A-Z]



                    7.[...]



                    The < hyphen-minus > character shall be treated as itself if it occurs
                    first (after an initial ^, if any) or last in the list, or as an
                    ending range point in a range expression. As examples, the expressions
                    [-ac] and [ac-] are equivalent and match any of the characters
                    'a', 'c', or '-'; [^-ac] and [^ac-] are equivalent and match any
                    characters except 'a', 'c', or '-'; [...]



                    If a bracket expression specifies both '-' and ']', the ']' shall be
                    placed first (after the '^', if any) and the '-' last within the
                    bracket expression.







                    share|improve this answer























                    • It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
                      – Isaac
                      Jun 6 at 21:06














                    up vote
                    1
                    down vote













                    The hyphen - is special character in character class (Bracket Expression) which specifying the character range. If you want add literal - into your character class you will need to either escape it or move it to the end or beginning (after the ^, if any) of your character class.



                    [a-z-]
                    [-a-z]
                    [a-z-A-Z]



                    7.[...]



                    The < hyphen-minus > character shall be treated as itself if it occurs
                    first (after an initial ^, if any) or last in the list, or as an
                    ending range point in a range expression. As examples, the expressions
                    [-ac] and [ac-] are equivalent and match any of the characters
                    'a', 'c', or '-'; [^-ac] and [^ac-] are equivalent and match any
                    characters except 'a', 'c', or '-'; [...]



                    If a bracket expression specifies both '-' and ']', the ']' shall be
                    placed first (after the '^', if any) and the '-' last within the
                    bracket expression.







                    share|improve this answer























                    • It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
                      – Isaac
                      Jun 6 at 21:06












                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    The hyphen - is special character in character class (Bracket Expression) which specifying the character range. If you want add literal - into your character class you will need to either escape it or move it to the end or beginning (after the ^, if any) of your character class.



                    [a-z-]
                    [-a-z]
                    [a-z-A-Z]



                    7.[...]



                    The < hyphen-minus > character shall be treated as itself if it occurs
                    first (after an initial ^, if any) or last in the list, or as an
                    ending range point in a range expression. As examples, the expressions
                    [-ac] and [ac-] are equivalent and match any of the characters
                    'a', 'c', or '-'; [^-ac] and [^ac-] are equivalent and match any
                    characters except 'a', 'c', or '-'; [...]



                    If a bracket expression specifies both '-' and ']', the ']' shall be
                    placed first (after the '^', if any) and the '-' last within the
                    bracket expression.







                    share|improve this answer















                    The hyphen - is special character in character class (Bracket Expression) which specifying the character range. If you want add literal - into your character class you will need to either escape it or move it to the end or beginning (after the ^, if any) of your character class.



                    [a-z-]
                    [-a-z]
                    [a-z-A-Z]



                    7.[...]



                    The < hyphen-minus > character shall be treated as itself if it occurs
                    first (after an initial ^, if any) or last in the list, or as an
                    ending range point in a range expression. As examples, the expressions
                    [-ac] and [ac-] are equivalent and match any of the characters
                    'a', 'c', or '-'; [^-ac] and [^ac-] are equivalent and match any
                    characters except 'a', 'c', or '-'; [...]



                    If a bracket expression specifies both '-' and ']', the ']' shall be
                    placed first (after the '^', if any) and the '-' last within the
                    bracket expression.








                    share|improve this answer















                    share|improve this answer



                    share|improve this answer








                    edited Jun 6 at 15:06


























                    answered Jun 6 at 10:34









                    αғsнιη

                    14.7k82361




                    14.7k82361











                    • It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
                      – Isaac
                      Jun 6 at 21:06
















                    • It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
                      – Isaac
                      Jun 6 at 21:06















                    It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
                    – Isaac
                    Jun 6 at 21:06




                    It is not a good idea to escape characters inside "bracket expressions" as that will not work in most other extended regexes.
                    – Isaac
                    Jun 6 at 21:06










                    up vote
                    0
                    down vote













                    Which version of awk are you using?



                    This command does not error when I use GNU awk, although it produces no output.



                    Using solaris awk it produces this error:



                    awk: syntax error near line 1
                    awk: bailing out near line 1


                    Reading through your regex, it's never going to match an email address...






                    share|improve this answer























                    • I use GNU Awk 4.1.3 under ubuntu 16.04.
                      – sci9
                      Jun 6 at 10:01










                    • "Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
                      – sci9
                      Jun 6 at 10:03














                    up vote
                    0
                    down vote













                    Which version of awk are you using?



                    This command does not error when I use GNU awk, although it produces no output.



                    Using solaris awk it produces this error:



                    awk: syntax error near line 1
                    awk: bailing out near line 1


                    Reading through your regex, it's never going to match an email address...






                    share|improve this answer























                    • I use GNU Awk 4.1.3 under ubuntu 16.04.
                      – sci9
                      Jun 6 at 10:01










                    • "Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
                      – sci9
                      Jun 6 at 10:03












                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    Which version of awk are you using?



                    This command does not error when I use GNU awk, although it produces no output.



                    Using solaris awk it produces this error:



                    awk: syntax error near line 1
                    awk: bailing out near line 1


                    Reading through your regex, it's never going to match an email address...






                    share|improve this answer















                    Which version of awk are you using?



                    This command does not error when I use GNU awk, although it produces no output.



                    Using solaris awk it produces this error:



                    awk: syntax error near line 1
                    awk: bailing out near line 1


                    Reading through your regex, it's never going to match an email address...







                    share|improve this answer















                    share|improve this answer



                    share|improve this answer








                    edited Jun 6 at 10:01


























                    answered Jun 6 at 9:59









                    rusty shackleford

                    1,135115




                    1,135115











                    • I use GNU Awk 4.1.3 under ubuntu 16.04.
                      – sci9
                      Jun 6 at 10:01










                    • "Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
                      – sci9
                      Jun 6 at 10:03
















                    • I use GNU Awk 4.1.3 under ubuntu 16.04.
                      – sci9
                      Jun 6 at 10:01










                    • "Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
                      – sci9
                      Jun 6 at 10:03















                    I use GNU Awk 4.1.3 under ubuntu 16.04.
                    – sci9
                    Jun 6 at 10:01




                    I use GNU Awk 4.1.3 under ubuntu 16.04.
                    – sci9
                    Jun 6 at 10:01












                    "Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
                    – sci9
                    Jun 6 at 10:03




                    "Reading through your regex, it's never going to match an email address..." : Yes, I put the correct regex. Please see the new edition.
                    – sci9
                    Jun 6 at 10:03












                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448145%2fawk-error-tent-of%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    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