notepad++ regexp to find all lines which contain a specific string












7















I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.










share|improve this question

























  • Make the regexp match the beginning of a line through the n or rn at the ends of them (depending on the convention being used), and them make the replacement string nothing.

    – martineau
    Jan 25 '11 at 12:05
















7















I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.










share|improve this question

























  • Make the regexp match the beginning of a line through the n or rn at the ends of them (depending on the convention being used), and them make the replacement string nothing.

    – martineau
    Jan 25 '11 at 12:05














7












7








7


3






I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.










share|improve this question
















I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.







notepad++ regex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 18 '11 at 23:58









studiohack

11.3k1880113




11.3k1880113










asked Jan 25 '11 at 9:32









clampclamp

46472239




46472239













  • Make the regexp match the beginning of a line through the n or rn at the ends of them (depending on the convention being used), and them make the replacement string nothing.

    – martineau
    Jan 25 '11 at 12:05



















  • Make the regexp match the beginning of a line through the n or rn at the ends of them (depending on the convention being used), and them make the replacement string nothing.

    – martineau
    Jan 25 '11 at 12:05

















Make the regexp match the beginning of a line through the n or rn at the ends of them (depending on the convention being used), and them make the replacement string nothing.

– martineau
Jan 25 '11 at 12:05





Make the regexp match the beginning of a line through the n or rn at the ends of them (depending on the convention being used), and them make the replacement string nothing.

– martineau
Jan 25 '11 at 12:05










4 Answers
4






active

oldest

votes


















17














Well I don't think you can do it with one search-replace.



I'd do this.



Open up the search-replace, choose mode regex and search for:



^.*(string).*$ and let the replacement be 1 (this is the string marking the lines you don't want). This will leave lines with only the unwanted string and nothing else.



Then switch to the extended search and search for rnstring and leave the replacement blank. This will delete the lines with only the unwanted string in it.



There's probably a neater way to do it but this works.



Edit: and oh, check the first line of the document too for a line with only the unwanted string as this will miss those. As said, there's probably a better way. ;)






share|improve this answer
























  • Do you mean he should do notepad++'s REPLACE ALL then. ok

    – barlop
    Feb 28 '14 at 12:10





















1














To find multiple strings on the same line you can use ^.*(string).*(string).*$






share|improve this answer

































    1














    Make sure that you are unchecking the option .matches newline.



    enter image description here






    share|improve this answer































      1














      So, I wanted to delete an entire line if it contained one of three words: LAB,RAD,TRAN. So what I did was a "find and replace" in Notepad++ where I match the whole line if it contains one of these words. Additionally though I have it match the new line (n) and return carriage (r) characters and replaced the whole thing blank (e.i. nothing). That way when it does the replace it remove all the text including the hidden characters that give you a new line. This made it so it didn't leave a blank line after replacement



      REGEX:



      .*((LAB)|(RAD)|(TRAN)).*rn






      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        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%2fsuperuser.com%2fquestions%2f237515%2fnotepad-regexp-to-find-all-lines-which-contain-a-specific-string%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









        17














        Well I don't think you can do it with one search-replace.



        I'd do this.



        Open up the search-replace, choose mode regex and search for:



        ^.*(string).*$ and let the replacement be 1 (this is the string marking the lines you don't want). This will leave lines with only the unwanted string and nothing else.



        Then switch to the extended search and search for rnstring and leave the replacement blank. This will delete the lines with only the unwanted string in it.



        There's probably a neater way to do it but this works.



        Edit: and oh, check the first line of the document too for a line with only the unwanted string as this will miss those. As said, there's probably a better way. ;)






        share|improve this answer
























        • Do you mean he should do notepad++'s REPLACE ALL then. ok

          – barlop
          Feb 28 '14 at 12:10


















        17














        Well I don't think you can do it with one search-replace.



        I'd do this.



        Open up the search-replace, choose mode regex and search for:



        ^.*(string).*$ and let the replacement be 1 (this is the string marking the lines you don't want). This will leave lines with only the unwanted string and nothing else.



        Then switch to the extended search and search for rnstring and leave the replacement blank. This will delete the lines with only the unwanted string in it.



        There's probably a neater way to do it but this works.



        Edit: and oh, check the first line of the document too for a line with only the unwanted string as this will miss those. As said, there's probably a better way. ;)






        share|improve this answer
























        • Do you mean he should do notepad++'s REPLACE ALL then. ok

          – barlop
          Feb 28 '14 at 12:10
















        17












        17








        17







        Well I don't think you can do it with one search-replace.



        I'd do this.



        Open up the search-replace, choose mode regex and search for:



        ^.*(string).*$ and let the replacement be 1 (this is the string marking the lines you don't want). This will leave lines with only the unwanted string and nothing else.



        Then switch to the extended search and search for rnstring and leave the replacement blank. This will delete the lines with only the unwanted string in it.



        There's probably a neater way to do it but this works.



        Edit: and oh, check the first line of the document too for a line with only the unwanted string as this will miss those. As said, there's probably a better way. ;)






        share|improve this answer













        Well I don't think you can do it with one search-replace.



        I'd do this.



        Open up the search-replace, choose mode regex and search for:



        ^.*(string).*$ and let the replacement be 1 (this is the string marking the lines you don't want). This will leave lines with only the unwanted string and nothing else.



        Then switch to the extended search and search for rnstring and leave the replacement blank. This will delete the lines with only the unwanted string in it.



        There's probably a neater way to do it but this works.



        Edit: and oh, check the first line of the document too for a line with only the unwanted string as this will miss those. As said, there's probably a better way. ;)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 25 '11 at 11:53









        JaHeiJaHei

        554311




        554311













        • Do you mean he should do notepad++'s REPLACE ALL then. ok

          – barlop
          Feb 28 '14 at 12:10





















        • Do you mean he should do notepad++'s REPLACE ALL then. ok

          – barlop
          Feb 28 '14 at 12:10



















        Do you mean he should do notepad++'s REPLACE ALL then. ok

        – barlop
        Feb 28 '14 at 12:10







        Do you mean he should do notepad++'s REPLACE ALL then. ok

        – barlop
        Feb 28 '14 at 12:10















        1














        To find multiple strings on the same line you can use ^.*(string).*(string).*$






        share|improve this answer






























          1














          To find multiple strings on the same line you can use ^.*(string).*(string).*$






          share|improve this answer




























            1












            1








            1







            To find multiple strings on the same line you can use ^.*(string).*(string).*$






            share|improve this answer















            To find multiple strings on the same line you can use ^.*(string).*(string).*$







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 2 '12 at 21:05









            bwDraco

            36.6k36135177




            36.6k36135177










            answered May 2 '12 at 20:52









            TomTom

            111




            111























                1














                Make sure that you are unchecking the option .matches newline.



                enter image description here






                share|improve this answer




























                  1














                  Make sure that you are unchecking the option .matches newline.



                  enter image description here






                  share|improve this answer


























                    1












                    1








                    1







                    Make sure that you are unchecking the option .matches newline.



                    enter image description here






                    share|improve this answer













                    Make sure that you are unchecking the option .matches newline.



                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 28 '14 at 11:03









                    Vishnu HaridasVishnu Haridas

                    1113




                    1113























                        1














                        So, I wanted to delete an entire line if it contained one of three words: LAB,RAD,TRAN. So what I did was a "find and replace" in Notepad++ where I match the whole line if it contains one of these words. Additionally though I have it match the new line (n) and return carriage (r) characters and replaced the whole thing blank (e.i. nothing). That way when it does the replace it remove all the text including the hidden characters that give you a new line. This made it so it didn't leave a blank line after replacement



                        REGEX:



                        .*((LAB)|(RAD)|(TRAN)).*rn






                        share|improve this answer




























                          1














                          So, I wanted to delete an entire line if it contained one of three words: LAB,RAD,TRAN. So what I did was a "find and replace" in Notepad++ where I match the whole line if it contains one of these words. Additionally though I have it match the new line (n) and return carriage (r) characters and replaced the whole thing blank (e.i. nothing). That way when it does the replace it remove all the text including the hidden characters that give you a new line. This made it so it didn't leave a blank line after replacement



                          REGEX:



                          .*((LAB)|(RAD)|(TRAN)).*rn






                          share|improve this answer


























                            1












                            1








                            1







                            So, I wanted to delete an entire line if it contained one of three words: LAB,RAD,TRAN. So what I did was a "find and replace" in Notepad++ where I match the whole line if it contains one of these words. Additionally though I have it match the new line (n) and return carriage (r) characters and replaced the whole thing blank (e.i. nothing). That way when it does the replace it remove all the text including the hidden characters that give you a new line. This made it so it didn't leave a blank line after replacement



                            REGEX:



                            .*((LAB)|(RAD)|(TRAN)).*rn






                            share|improve this answer













                            So, I wanted to delete an entire line if it contained one of three words: LAB,RAD,TRAN. So what I did was a "find and replace" in Notepad++ where I match the whole line if it contains one of these words. Additionally though I have it match the new line (n) and return carriage (r) characters and replaced the whole thing blank (e.i. nothing). That way when it does the replace it remove all the text including the hidden characters that give you a new line. This made it so it didn't leave a blank line after replacement



                            REGEX:



                            .*((LAB)|(RAD)|(TRAN)).*rn







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Aug 22 '14 at 21:15









                            Jason WhitingJason Whiting

                            111




                            111






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Super User!


                                • 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%2fsuperuser.com%2fquestions%2f237515%2fnotepad-regexp-to-find-all-lines-which-contain-a-specific-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 make a Squid Proxy server?

                                第一次世界大戦

                                Touch on Surface Book