1 not defined in the RE?












2















My code goes like this:



cat file.ign | sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


Yet I receive an error saying :



sed: 1: "s/^([^A-Za-z0-9]+ )/<ig ...": 1 not defined in the RE


For the life of me, I cannot figure out my misdoing. If you need any extra information for helping me, let me know and I will reply.










share|improve this question









New contributor




Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    2















    My code goes like this:



    cat file.ign | sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


    Yet I receive an error saying :



    sed: 1: "s/^([^A-Za-z0-9]+ )/<ig ...": 1 not defined in the RE


    For the life of me, I cannot figure out my misdoing. If you need any extra information for helping me, let me know and I will reply.










    share|improve this question









    New contributor




    Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      2












      2








      2








      My code goes like this:



      cat file.ign | sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


      Yet I receive an error saying :



      sed: 1: "s/^([^A-Za-z0-9]+ )/<ig ...": 1 not defined in the RE


      For the life of me, I cannot figure out my misdoing. If you need any extra information for helping me, let me know and I will reply.










      share|improve this question









      New contributor




      Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      My code goes like this:



      cat file.ign | sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


      Yet I receive an error saying :



      sed: 1: "s/^([^A-Za-z0-9]+ )/<ig ...": 1 not defined in the RE


      For the life of me, I cannot figure out my misdoing. If you need any extra information for helping me, let me know and I will reply.







      sed






      share|improve this question









      New contributor




      Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 3 hours ago









      Jeff Schaller

      40.9k1056131




      40.9k1056131






      New contributor




      Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 hours ago









      Laura Laura

      111




      111




      New contributor




      Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Laura is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          5














          Parentheses are literal in basic regular expression (BRE) syntax - to make them denote a capture group, they must be escaped, as ( and )



          Additionally, as noted in a comment by @BenjaminW, + is also literal in BRE. GNU sed supports + as a quantifier in BRE:



          sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          (but other implementations might not). Alternatively, turn on extended regular expression (ERE) mode using the -E or -r command line switch as appropriate (check your version's documentation):



          sed -E 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          or use the POSIX-compliant quantifier {1,}



          sed 's/^([^A-Za-z0-9]{1,} )/<ignore>1</ignore>/g'


          ASIDE the g (global replacement) modifier won't have any effect here, since ^ anchors the expression to the start of the pattern (which can occur only once per line)






          share|improve this answer





















          • 1





            Furthermore, + is only avalable in ERE; GNU sed supports it as an extension in BRE, but is has to be escaped.

            – Benjamin W.
            2 hours ago











          • @BenjaminW. oops yes that's a good point - I missed that

            – steeldriver
            2 hours ago











          • The -E also is GNU or FreeBSD sed, not in POSIX. If you're going to recommend a non-POSIX solution, mentioning that might help the reader.

            – Thomas Dickey
            1 hour ago













          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          });


          }
          });






          Laura is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499185%2f1-not-defined-in-the-re%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5














          Parentheses are literal in basic regular expression (BRE) syntax - to make them denote a capture group, they must be escaped, as ( and )



          Additionally, as noted in a comment by @BenjaminW, + is also literal in BRE. GNU sed supports + as a quantifier in BRE:



          sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          (but other implementations might not). Alternatively, turn on extended regular expression (ERE) mode using the -E or -r command line switch as appropriate (check your version's documentation):



          sed -E 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          or use the POSIX-compliant quantifier {1,}



          sed 's/^([^A-Za-z0-9]{1,} )/<ignore>1</ignore>/g'


          ASIDE the g (global replacement) modifier won't have any effect here, since ^ anchors the expression to the start of the pattern (which can occur only once per line)






          share|improve this answer





















          • 1





            Furthermore, + is only avalable in ERE; GNU sed supports it as an extension in BRE, but is has to be escaped.

            – Benjamin W.
            2 hours ago











          • @BenjaminW. oops yes that's a good point - I missed that

            – steeldriver
            2 hours ago











          • The -E also is GNU or FreeBSD sed, not in POSIX. If you're going to recommend a non-POSIX solution, mentioning that might help the reader.

            – Thomas Dickey
            1 hour ago


















          5














          Parentheses are literal in basic regular expression (BRE) syntax - to make them denote a capture group, they must be escaped, as ( and )



          Additionally, as noted in a comment by @BenjaminW, + is also literal in BRE. GNU sed supports + as a quantifier in BRE:



          sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          (but other implementations might not). Alternatively, turn on extended regular expression (ERE) mode using the -E or -r command line switch as appropriate (check your version's documentation):



          sed -E 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          or use the POSIX-compliant quantifier {1,}



          sed 's/^([^A-Za-z0-9]{1,} )/<ignore>1</ignore>/g'


          ASIDE the g (global replacement) modifier won't have any effect here, since ^ anchors the expression to the start of the pattern (which can occur only once per line)






          share|improve this answer





















          • 1





            Furthermore, + is only avalable in ERE; GNU sed supports it as an extension in BRE, but is has to be escaped.

            – Benjamin W.
            2 hours ago











          • @BenjaminW. oops yes that's a good point - I missed that

            – steeldriver
            2 hours ago











          • The -E also is GNU or FreeBSD sed, not in POSIX. If you're going to recommend a non-POSIX solution, mentioning that might help the reader.

            – Thomas Dickey
            1 hour ago
















          5












          5








          5







          Parentheses are literal in basic regular expression (BRE) syntax - to make them denote a capture group, they must be escaped, as ( and )



          Additionally, as noted in a comment by @BenjaminW, + is also literal in BRE. GNU sed supports + as a quantifier in BRE:



          sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          (but other implementations might not). Alternatively, turn on extended regular expression (ERE) mode using the -E or -r command line switch as appropriate (check your version's documentation):



          sed -E 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          or use the POSIX-compliant quantifier {1,}



          sed 's/^([^A-Za-z0-9]{1,} )/<ignore>1</ignore>/g'


          ASIDE the g (global replacement) modifier won't have any effect here, since ^ anchors the expression to the start of the pattern (which can occur only once per line)






          share|improve this answer















          Parentheses are literal in basic regular expression (BRE) syntax - to make them denote a capture group, they must be escaped, as ( and )



          Additionally, as noted in a comment by @BenjaminW, + is also literal in BRE. GNU sed supports + as a quantifier in BRE:



          sed 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          (but other implementations might not). Alternatively, turn on extended regular expression (ERE) mode using the -E or -r command line switch as appropriate (check your version's documentation):



          sed -E 's/^([^A-Za-z0-9]+ )/<ignore>1</ignore>/g'


          or use the POSIX-compliant quantifier {1,}



          sed 's/^([^A-Za-z0-9]{1,} )/<ignore>1</ignore>/g'


          ASIDE the g (global replacement) modifier won't have any effect here, since ^ anchors the expression to the start of the pattern (which can occur only once per line)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 1 hour ago

























          answered 3 hours ago









          steeldriversteeldriver

          36k35286




          36k35286








          • 1





            Furthermore, + is only avalable in ERE; GNU sed supports it as an extension in BRE, but is has to be escaped.

            – Benjamin W.
            2 hours ago











          • @BenjaminW. oops yes that's a good point - I missed that

            – steeldriver
            2 hours ago











          • The -E also is GNU or FreeBSD sed, not in POSIX. If you're going to recommend a non-POSIX solution, mentioning that might help the reader.

            – Thomas Dickey
            1 hour ago
















          • 1





            Furthermore, + is only avalable in ERE; GNU sed supports it as an extension in BRE, but is has to be escaped.

            – Benjamin W.
            2 hours ago











          • @BenjaminW. oops yes that's a good point - I missed that

            – steeldriver
            2 hours ago











          • The -E also is GNU or FreeBSD sed, not in POSIX. If you're going to recommend a non-POSIX solution, mentioning that might help the reader.

            – Thomas Dickey
            1 hour ago










          1




          1





          Furthermore, + is only avalable in ERE; GNU sed supports it as an extension in BRE, but is has to be escaped.

          – Benjamin W.
          2 hours ago





          Furthermore, + is only avalable in ERE; GNU sed supports it as an extension in BRE, but is has to be escaped.

          – Benjamin W.
          2 hours ago













          @BenjaminW. oops yes that's a good point - I missed that

          – steeldriver
          2 hours ago





          @BenjaminW. oops yes that's a good point - I missed that

          – steeldriver
          2 hours ago













          The -E also is GNU or FreeBSD sed, not in POSIX. If you're going to recommend a non-POSIX solution, mentioning that might help the reader.

          – Thomas Dickey
          1 hour ago







          The -E also is GNU or FreeBSD sed, not in POSIX. If you're going to recommend a non-POSIX solution, mentioning that might help the reader.

          – Thomas Dickey
          1 hour ago












          Laura is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Laura is a new contributor. Be nice, and check out our Code of Conduct.













          Laura is a new contributor. Be nice, and check out our Code of Conduct.












          Laura is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f499185%2f1-not-defined-in-the-re%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

          Сан-Квентин

          Алькесар

          Josef Freinademetz