notepad++ regexp to find all lines which contain a specific string
I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.
notepad++ regex
add a comment |
I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.
notepad++ regex
Make the regexp match the beginning of a line through thenorrnat the ends of them (depending on the convention being used), and them make the replacement string nothing.
– martineau
Jan 25 '11 at 12:05
add a comment |
I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.
notepad++ regex
I am looking for a notepad++ regexp that contains a specific string.
I then want to delete this whole line.
notepad++ regex
notepad++ regex
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 thenorrnat the ends of them (depending on the convention being used), and them make the replacement string nothing.
– martineau
Jan 25 '11 at 12:05
add a comment |
Make the regexp match the beginning of a line through thenorrnat 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
add a comment |
4 Answers
4
active
oldest
votes
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. ;)
Do you mean he should do notepad++'s REPLACE ALL then. ok
– barlop
Feb 28 '14 at 12:10
add a comment |
To find multiple strings on the same line you can use ^.*(string).*(string).*$
add a comment |
Make sure that you are unchecking the option .matches newline.

add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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. ;)
Do you mean he should do notepad++'s REPLACE ALL then. ok
– barlop
Feb 28 '14 at 12:10
add a comment |
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. ;)
Do you mean he should do notepad++'s REPLACE ALL then. ok
– barlop
Feb 28 '14 at 12:10
add a comment |
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. ;)
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. ;)
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
add a comment |
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
add a comment |
To find multiple strings on the same line you can use ^.*(string).*(string).*$
add a comment |
To find multiple strings on the same line you can use ^.*(string).*(string).*$
add a comment |
To find multiple strings on the same line you can use ^.*(string).*(string).*$
To find multiple strings on the same line you can use ^.*(string).*(string).*$
edited May 2 '12 at 21:05
bwDraco
36.6k36135177
36.6k36135177
answered May 2 '12 at 20:52
TomTom
111
111
add a comment |
add a comment |
Make sure that you are unchecking the option .matches newline.

add a comment |
Make sure that you are unchecking the option .matches newline.

add a comment |
Make sure that you are unchecking the option .matches newline.

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

answered Feb 28 '14 at 11:03
Vishnu HaridasVishnu Haridas
1113
1113
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Aug 22 '14 at 21:15
Jason WhitingJason Whiting
111
111
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Make the regexp match the beginning of a line through the
norrnat the ends of them (depending on the convention being used), and them make the replacement string nothing.– martineau
Jan 25 '11 at 12:05