How to remove multiple lines?
-
I have this text file like this
https://bnasicoasdasasdasfo.biz:2083|cthakzzq|Ch3
https://bnasfasfasdaso.com:2083|vichlvcl|Ch
https://bodasdasdasdlutions.com:2083|hd
https://cbasdasdv.com:2083|lmbdbaps|Ch3tos@1
https://cbdtasdasd.com:2083|rcjmsfgx|Ch3tosI want to delete lines containing https://***:2083
Also if possible want to delete lines containing . like
domain.com or domain.net -
Welcome to the Notepad++ Community Forum. I will append some useful generic information at the end of this post for how to ask your question in a way that will improve the quality of answers that you get, and provides links for how to learn how to do the fancy search/replace on your own rather than relying on us. Avail yourself of that advice.
I will do my best to answer based on the information you have given.
You will want to use the “regular expression” search mode.
Your first request said,
I want to delete lines containing https://***:2083
The notation you gave was very nearly the regex expression needed for mathcing that portion.
.+
will match 1 or more of any character. If you restrict it to “as few as possible”,.+?
, then it will go from thehttps://
to the first:2083
in the match.Then, all you have to do is add the regex syntax for grabbing the first part of the line and last part of the line (including newline or end of file), and bring it all together
- FIND =
^.*?https://.+?:2083.*?(\R|\Z)
- REPLACE = empty
- Search Mode = regular expression
- Uncheck
. matches newline
- REPLACE ALL
Translates:
keep https://bnasicoasdasasdasfo.biz:2083|cthakzzq|Ch3 keep https://bnasfasfasdaso.com:2083|vichlvcl|Ch keep https://bodasdasdasdlutions.com:2083|hd keep
into
keep keep keep keep
if possible want to delete lines containing . like domain.com or domain.net
To match a literal
.
character in a regex, escape it like\.
So the pattern will be start-of-line, 0 or more chars, literal
.
, 0 or more chars, end-of-line/end-of-file- FIND =
^.*?\..*?(\R|\Z)
- REPLACE = empty
- Search Mode = regular expression
- Uncheck
. matches newline
- REPLACE ALL
translates
This line has no dot This ends in dot. .This started in dot domain.com domain.net no dot
to
This line has no dot no dot
Please note that better examples, with lines to delete and lines to keep, would help us confirm the regex works before we post our answer, rather than you having to tell us, “no, I really meant xxx”.
Please note that this forum is not a “do my data transformation for me”, or even a “generic regex help forum”. We will give new users a couple of rounds of regex help, but really, this forum is about so much more than just “make my data change from X to Y”. You will get better help if you show an effort and willingness to learn.
----
Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the
</>
toolbar button or manual Markdown syntax. To makeregex in red
(and so they keep their special characters like *), use backticks, like`^.*?blah.*?\z`
. Screenshots can be pasted from the clipboard to your post usingCtrl+V
to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries. - FIND =