Remove specific words containing dots from a string












0












$begingroup$


Hi I got words that contain one of the following tokens: CO. PRO. IST.

How to clean my words from these tokens? Do you have any regex pattern?



for example the words :



convolutional NN in data science--> extract nothing   
co. Neural N --> extract co
co NN --> extract nothing


Thanks!










share|improve this question









$endgroup$

















    0












    $begingroup$


    Hi I got words that contain one of the following tokens: CO. PRO. IST.

    How to clean my words from these tokens? Do you have any regex pattern?



    for example the words :



    convolutional NN in data science--> extract nothing   
    co. Neural N --> extract co
    co NN --> extract nothing


    Thanks!










    share|improve this question









    $endgroup$















      0












      0








      0





      $begingroup$


      Hi I got words that contain one of the following tokens: CO. PRO. IST.

      How to clean my words from these tokens? Do you have any regex pattern?



      for example the words :



      convolutional NN in data science--> extract nothing   
      co. Neural N --> extract co
      co NN --> extract nothing


      Thanks!










      share|improve this question









      $endgroup$




      Hi I got words that contain one of the following tokens: CO. PRO. IST.

      How to clean my words from these tokens? Do you have any regex pattern?



      for example the words :



      convolutional NN in data science--> extract nothing   
      co. Neural N --> extract co
      co NN --> extract nothing


      Thanks!







      r rstudio regex dplyr






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 18 hours ago









      3nomis3nomis

      1827




      1827






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          you can use lookahead with str_extract from the stringr package.



          e.g.



          stringr::str_extract(string = "co.asdkhsda", pattern = "co(?=\.)") 
          # extracts 'co' only when followed by a literal '.'

          stringr::str_extract("convolutional NN in data science", pattern = "co(?=\.)")
          # extracts nothing, returns NA


          The regex pattern



          co(?=\.) 


          looks for 'co', followed by '\.'



          The '\'-part is used to escape the special meaning of the '.'



          The dot usually matches any character, and therefore need to be escaped.






          share|improve this answer








          New contributor




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






          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "557"
            };
            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
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f45804%2fremove-specific-words-containing-dots-from-a-string%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









            0












            $begingroup$

            you can use lookahead with str_extract from the stringr package.



            e.g.



            stringr::str_extract(string = "co.asdkhsda", pattern = "co(?=\.)") 
            # extracts 'co' only when followed by a literal '.'

            stringr::str_extract("convolutional NN in data science", pattern = "co(?=\.)")
            # extracts nothing, returns NA


            The regex pattern



            co(?=\.) 


            looks for 'co', followed by '\.'



            The '\'-part is used to escape the special meaning of the '.'



            The dot usually matches any character, and therefore need to be escaped.






            share|improve this answer








            New contributor




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






            $endgroup$


















              0












              $begingroup$

              you can use lookahead with str_extract from the stringr package.



              e.g.



              stringr::str_extract(string = "co.asdkhsda", pattern = "co(?=\.)") 
              # extracts 'co' only when followed by a literal '.'

              stringr::str_extract("convolutional NN in data science", pattern = "co(?=\.)")
              # extracts nothing, returns NA


              The regex pattern



              co(?=\.) 


              looks for 'co', followed by '\.'



              The '\'-part is used to escape the special meaning of the '.'



              The dot usually matches any character, and therefore need to be escaped.






              share|improve this answer








              New contributor




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






              $endgroup$
















                0












                0








                0





                $begingroup$

                you can use lookahead with str_extract from the stringr package.



                e.g.



                stringr::str_extract(string = "co.asdkhsda", pattern = "co(?=\.)") 
                # extracts 'co' only when followed by a literal '.'

                stringr::str_extract("convolutional NN in data science", pattern = "co(?=\.)")
                # extracts nothing, returns NA


                The regex pattern



                co(?=\.) 


                looks for 'co', followed by '\.'



                The '\'-part is used to escape the special meaning of the '.'



                The dot usually matches any character, and therefore need to be escaped.






                share|improve this answer








                New contributor




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






                $endgroup$



                you can use lookahead with str_extract from the stringr package.



                e.g.



                stringr::str_extract(string = "co.asdkhsda", pattern = "co(?=\.)") 
                # extracts 'co' only when followed by a literal '.'

                stringr::str_extract("convolutional NN in data science", pattern = "co(?=\.)")
                # extracts nothing, returns NA


                The regex pattern



                co(?=\.) 


                looks for 'co', followed by '\.'



                The '\'-part is used to escape the special meaning of the '.'



                The dot usually matches any character, and therefore need to be escaped.







                share|improve this answer








                New contributor




                Jagge 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 answer



                share|improve this answer






                New contributor




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









                answered 15 hours ago









                JaggeJagge

                1




                1




                New contributor




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





                New contributor





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






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






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Data Science 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.


                    Use MathJax to format equations. MathJax reference.


                    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%2fdatascience.stackexchange.com%2fquestions%2f45804%2fremove-specific-words-containing-dots-from-a-string%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 label and detect the document text images

                    Vallis Paradisi

                    Tabula Rosettana