delete line between bookmark
-
@pinuzzu99 and All,
Oh… I forgot to mention that you need to use the
Replace All
button , only. Do not use theReplace
button which does not act as it should, when the regex contain any\K
syntax. This is a general rule, available for any regex containing, at least, one\K
syntaxBest Regards,
guy038
-
yes i know, Replace All and i have try it before my post above, but as i said, i want check all my single block one by one before delete all lines.
for my purpose work fine this: (?-s).*\R(?s:.+?)(?=^.+@)
without \K and work with Replace, but on next block i need to put cursor at begin line under mail line…
this is little problem if my txt have 10,000 block of mail - file list… -
in this specific case string (?-s).*\R(?s:.+?)(?=^.+@) don’t find value…
why? what is different than other blocks?earlnathanieluhftr@gmail.com:natchel7634 Used: 3/50GB Physiology 0KB Internal Med 0KB Passwords.zip 370KB Lippincott Illustrated Reviews Flash Cards Physiology - Preston, Robin [SRG].pdf 42137KB 08/09/2015 17:46:42 Ganongs Review of Medical Physiology, 24E (2012) [UnitedVRG].pdf 80607KB 08/09/2015 17:46:36 Kaplan USMLE Step 1 Physiology Lecture Notes (2013) [PDF] [UnitedVRG].pdf 25312KB 08/09/2015 12:50:40
-
@pinuzzu99 said in delete line between bookmark:
i want check all my single block one by one before delete all lines.
But as @guy038 said, that expression won’t work in one-at-a-time mode. Continuing to try is an exercise in futility.
If you are uncertain whether the regex will meet all your needs, and you want to be able to compare the “before” and “after” states of your file, I recommend opening the original file
blah.txt
, File > Save copy as, give it a name likeblah_new.txt
, then openblah_new.txt
and move to other view – so that the two panes of Notepad++ areblah.txt
on the left andblah_new.txt
on the right, then run Guy’s regex on theblah_new.txt
, then use the Compare plugin (which you can install from the Plugins Admin) to find and easily navigate through the differences between the files, and make sure everything is the way you want it. If they are all right, great; if most are right and just a couple aren’t quite right, then manually fix those last few; if there are many wrong, then run Undo, and try to update the regex to better do what you want. Once you are happy withblah_new.txt
, you can delete the originalblah.txt
(or rename toblah_old.txt
, then renameblah_new.txt
toblah.txt
.(Or, you can start by copying
blah.txt
toblah_old.txt
, and haveblah_old.txt
on the left andblah.txt
on the right, doing all your edits toblah.txt
, and eliminating the extra renames at the end of the procedure.) -
i already save one backup of my txt…
and yes, compare plugin, i have and already use this.
however Document Map is very useful for scrolling through the file… -
i hope guy038 reply to my post (4 post above above this post)…
-
Hello @pinuzzu99, @Peterjones, @alan-kilborn and All,
Sorry, I did not even notice this post, which was rather short ;-)) Well, I suppose that the regex does not work because the last line
Kaplan USMLE Step 1 .....
is not followed with an e-mail address but is just the very end of your file !In order that this specific case will be taken in account, too, here is a other search regex :
-
Move to any line containing an e-mail address
-
Open the Search dialog (
Ctrl + F
) -
SEARCH
(?-s).*\R\K(?s:.+?)(?=^.+@|\z)
-
Tick the
Wrap around
option -
Select the
Regular expression
search mode -
Click on the
Find Next
button -
Hit the
ESC
key to close the Find dialog -
Now, hitting, repeatedly, on the
F3
key, it will select all text, after this e-mail address till the next e-mail address excluded and so on… OR till the very end of current file ! -
Of course, you may manually delete some of these blocks, with the
Delete
key, if necessary -
For a global suppression, leave the replacement zone
empty
and click on theReplace All
button
Moreover, if you want to move from one e-mail address to the next or the previous one, here is an simple method :
-
Open the Mark dialog (
Search > Mark...
) option -
SEARCH
@
-
Tick the
3
optionsBookmark line
,Purge for each search
andWrap around
-
Click on the
Mark All
button
=> Now, you can easily navigate betweens all these email addresses, using the
F2
and/orShift + F2
shortcutsBest Regards,
guy038
-
-
oh guy038 tank you so much for your reply! you are my super-hero!
2 really interesting things. it was what i wanted! many tanxs.only little curiosity: at the first part of your reply, about this code
(?-s).*\R\K(?s:.+?)(?=^.+@|\z)
work fine for my purposes, but i don’t understand why if i click (after the text block after mail has been selected) Replace with:empty
don’t delete simply this block… i have to exit thefind
and delete it manually with theDEL
key.
it would be very nice to remove the block with theReplace with
key… it’s not possible that?? -
…again… guys038 where did you end up ??
does not exist here in the forum the possibility to send a PM to a user? I do not think so…
-
Time to sit down and do some LEARNING and stop doing so much ASKING ?
-
dear sir… if i knew how to do it, I wouldn’t be here to waste time and ask others for advice, don’t you think?
think before writing, your speech is not welcome.
please avoid writing in my posts, your post is not required.
THANK YOU -
@pinuzzu99 said in delete line between bookmark:
does not exist here in the forum the possibility to send a PM to a user?
No, there is no PM capability.
if i knew how to do it, I wouldn’t be here to waste time and ask others for advice, don’t you think?
Guy has pointed you to the regex FAQ in your very first thread here. And again in your fourth thread here. Then, in your fifth thread, he again reminded you to follow Alan’s advice and learn the basics of regular expressions.
You need to show more effort, rather than demanding that we do your homework for you (at least, I hope it’s homework; if we’re doing the job you are being paid to do for you, that’s even worse), on your time schedule.
your speech is not welcome.
please avoid writing in my posts, your post is not required.I am sorry. You don’t get to decide who replies to your posts. Alan’s advice is sound advice: you need to put in the effort to start learning this.
In less than a month, you have done 6 different topics, four of which are regex based; as Guy pointed out, some of those have had very similar requirements. You have seen dozens of different regex suggestions from Guy and others on the forum. It is time for you to start learning what the bits of the regexes do, and try them yourself. If you get stuck, you can show us what you tried, and explain why you thought it should work, and we might be able to explain to you why it didn’t work for you, and point you in the right direction.
Please read the regex FAQ that has been linked for you. If that takes you to too many different locations, then please just focus on the official Notepad++ regex documentation.
Some more of my standard advice for people asking regex questions follows below:
-----Please Read And Understand This
FYI: I often add this to my response in regex threads, unless I am sure the original poster has seen it before. Here is some helpful information for finding out more about regular expressions, […]:
[…]
If you have further search-and-replace (“matching”, “marking”, “bookmarking”, regular expression, “regex”) needs, study the official Notepad++ searching using regular-expressions docs, as well as this forum’s FAQ and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting, see the paragraph above.
Please note that for all regex and related queries, it is best if you are explicit about what needs to match, and what shouldn’t match, and have multiple examples of both in your example dataset. Often, what shouldn’t match helps define the regular expression as much or more than what should match.
Here is the way I usually break down trying to figure out a regex (whether it’s for myself or for helping someone in the forum):
- Compare what portions of each line I want to match is identical to every other one (“constants”), and what parts do I want to allow to be different in each line (“variables”) but still be part of the match.
- Look at both the variables and constants, and see what portions of each I’ll want to keep or move around, vs which parts get thrown away completely. Each sub-component that I want to keep will be put in a regex group. Anything that gets completely thrown away doesn’t need to be in a group, though sometimes I put it in a numbered
(___)
or unnumbered(?:___)
group anyway, if I have a good reason for it. Anything that needs to be split apart, I break into multiple groups, instead of having it as one group.
- For each group, I do a mental “how would I describe to my son how to correctly match these characters?” – which should hopefully give me a simple, foolproof algorithm of characters that must match or must not match; then I ask, “how would I translate those instructions into regex sequences?” If I don’t know the answer to the second, I read documentation, or ask a specific question.
- try it, debug, iterate.
-
@pinuzzu99 said in delete line between bookmark:
dear sir… if i knew how to do it, I wouldn’t be here to waste time and ask others for advice, don’t you think?
think before writing, your speech is not welcome.
please avoid writing in my posts, your post is not required.
THANK YOUWow, that’s some serious gratitude; remember, I even wrote you a script earlier.
I wasn’t trying to be offensive to you, I was just trying to tell you that what you are trying to do isn’t really tolerated here.
-
I’m very sorry to have come to this, but someone’s behavior is really heavy …
I understand that I should learn but this code is not easy and i have to use it only on rare occasions and it doesn’t seem appropriate to study a code that i don’t need.
and yes Alan thank you for your advice above, but if you don’t want to help me for anything else, nobody forces you.
I am registered in numerous forums, and where i can i give my contribution. where I don’t know, I don’t answer. and everyone asks for things only for himself, but I have never, never, allowed myself to say learn if you don’t know. I write a suggestion about what he wants, stop.
and anyway to conclude, there are other forums, including stackoverflow, where others help without controversy. from now I will turn there.
I only hoped, since guy038 had shown me a way, that he would help me to reach a conclusion.
my post was addressed to him, who without controversy has kindly helped me to solve my problem.
however i apologize for my writing above, but sometimes it happens to lose patience on completely useless controversies …
I repeat, i believe that if one person can help others, he or she is better, otherwise it is better to refrain from controversy. regards. -
Hi, @pinuzzu99 and All,
I already explained to you, in this previous post, that if the
\K
syntax is present in the regex, this means that step by step replacement, by clicking theReplace
button, is not functional !https://community.notepad-plus-plus.org/post/50469
So, you have two possibilities, only :
A) Use a global replacement :
-
Move your caret to a line containing an e-mail address if you want to run the global replacement from current location till the very end of your file. If you want to process all the file, your present location does not matter
-
Open the Replace dialog (
Ctrl + H
) -
SEARCH
(?-s).*\R\K(?s:.+?)(?=^.+@|\z)
-
REPLACE
Leave EMPTY
-
Tick the
Wrap around
option, in order that the global replacement acts on the totality of your file -
Or untick the
Wrap around
option for a global replacement from current location till the very end of your file -
Select the
Regular expression
search mode -
Click, exclusively, on the
Replace All
button
B) Use the search feature and a manual suppression :
-
Whatever your current location, open the
Search
dialog (Ctrl + F
) -
SEARCH
(?-s).*\R\K(?s:.+?)(?=^.+@|\z)
-
Tick the
Wrap around
option, in order to navigate anywhere, throughout in your current file -
Select the
Regular expression
search mode -
Click once on the
Find Next
button, in order to memorize this regex -
Close the Find dialog with the
ESC
key -
Now, hit the
F3
key to get the bunch of lines following the next e-mail address -
If this selection is not wanted, just press the
Delete
key for suppression, else press, again, theF3
key for next search and so on…
Note that pressing the
Delete
key is a one-step operation, just like a single click on theReplace
button, anyway ;-))Best Regards
guy038
P.S :
Of course, the best would be to find a new regex S/R which does not need the
\K
feature. But to identify all lines between two e-mail addresses, I necessarily need to anchor to a first e-mail address, which must not be part of the overall regex match to prevent from deleting ! I’m still searching an other solution ;-)) -
-
@pinuzzu99 said in delete line between bookmark:
I’m very sorry to have come to this, but someone’s behavior is really heavy …
Your behavior is really greedy. You have asked many questions, demanded quick replies, requested specific attention, and never posted one helpful answer to anyone else’s questions.
it doesn’t seem appropriate to study a code that i don’t need.
It doesn’t seem appropriate for us to do your work for you. Since you have proven at least four times in the last month that you do need the tool (regex), claiming you don’t need it is deceiving yourself, at best.
You don’t have to become an expert at regex right away… and we don’t expect you to. However, we expect you to show some effort. Try some regexes, see if you can make them work for what you want to do. If you have trouble with one, show the regex you tried, show why you tried it, and explain what is wrong with the results it gives. With that much effort on your part, we will help you understand what you are doing wrong, so that we can help you learn. But if you just say “make this change for me – and make it right now! on my schedule!”, then you will not be able to learn.
if you don’t want to help me for anything else, nobody forces you.
You are not asking for help. you are asking us to write regexes for you, showing no effort to try to do them yourself. Throwing fish down your mouth isn’t helping you; teaching you how to fish is helping you; and asking that you at least learn how to cast the lure yourself, even if you’ve chosen the wrong lure for your specific fish, is a reasonable expectation.
I am registered in numerous forums, and where i can i give my contribution.
But you’ve never contributed anything but questions, and have shown a demanding, unwilling to try to learn attitude here. That’s all we have to go on. We haven’t seen you be willing to learn; we haven’t seen you try to help others. We have just seen your demands.
and anyway to conclude, there are other forums, including stackoverflow, where others help without controversy. from now I will turn there.
hahaha! Stack Overflow is about the most unhelpful forum I’ve ever seen. If you deign to ask a question similar to what’s been asked before, your question gets closed without any input from you.
I only hoped, since guy038 had shown me a way, that he would help me to reach a conclusion.
This is not personal one-on-one time. When Guy has opportunity, I am sure he will come back and answer your slight tweak. But demanding a certain person reply, and starting to ask “why haven’t you answered” after only 12 hours delay, is not polite forum behavior.
my post was addressed to him, who without controversy has kindly helped me to solve my problem.
But he has repeatedly asked you to show some effort, and you ignore that.
I repeat, i believe that if one person can help others, he or she is better, otherwise it is better to refrain from controversy. regards.
We are helping you. We are explaining to you the best way to get help: be polite, don’t be demanding, show that you are willing to try things and to learn.
Back to your question:
but i don’t understand why if i click (after the text block after mail has been selected) Replace with: empty don’t delete simply this block… i have to exit the find and delete it manually with the DEL key.
it would be very nice to remove the block with the Replace with key… it’s not possible that??It is possible to replace all. However, inside the dialog, single replaces don’t work with the
\K
, as Guy already explained to you. If you want to replace one at a time, you do the first search from the dialog, then exit out of the dialog box. From then on, DEL and F3 will allow you delete and then do the next one-at-a-time search.edit: I see that Guy posted the same thing while I was typing.
-
@PeterJones said in delete line between bookmark:
we expect you to show some effort. Try some regexes, see if you can make them work for what you want to do. If you have trouble with one, show the regex you tried, show why you tried it, and explain what is wrong with the results it gives
This is good and proper advice, but I think what the “takers” will start doing (to satisfy it) is grabbing the last freebie regex given to them, throw a couple of crap characters in it, and then post back, going “Wah wah it doesn’t work!”, without putting any real thought (or, forbid, learning) into it.
The “takers” seem to quickly establish a pattern in their behavior, as exemplified above, and in many other chains.
And all this in a forum that isn’t about regular expressions, but rather Notepad++!
-
@Alan-Kilborn said in delete line between bookmark:
@PeterJones said in delete line between bookmark:
we expect you to show some effort. Try some regexes, see if you can make them work for what you want to do. If you have trouble with one, show the regex you tried, show why you tried it, and explain what is wrong with the results it gives
This is good and proper advice, but I think what the “takers” will start doing (to satisfy it) is grabbing the last freebie regex given to them, throw a couple of crap characters in it, and then post back, going “Wah wah it doesn’t work!”, without putting any real thought (or, forbid, learning) into it.
That’s why here I said “show why you tried it”, and in my fuller boilerplate, I say, “why you thought that regex would work (to prove it wasn’t just something randomly typed)”
-
@PeterJones said in delete line between bookmark:
randomly typed
Heheh, hadn’t seen the “randomly typed” part before, but, not being the one that has ever needed to read your boilerplate thoroughly, I guess I’m not surprised. :-)
BTW, I can’t see any of the “takers” truly ever reading your BP either, but… :-)
-
with this post I always want to thank guy038 very much for his availability towards me.
moreover, @ PeterJones, leaving aside unnecessary controversy, I would just like to tell you that instead on Stackoverflow, since I wasn’t sure that guy038 was answering me, and since nobody was helping me here, I asked my question and not only as you say it has not been closed, but indeed they replied immediately, within a few minutes, solving my problem skillfully … in a few minutes …
so rest assured that I will no longer bother you here. luckily there are other forums, and other users (as I do when I can) who are happy to satisfy a request for help.
with this, however, a greeting to all. closed.