delete line between bookmark
-
@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. -
Hi, @pinuzzu99 and All,
That’s it, I got it !. In fact, the new regexes, below, are simply derived from the one given in a previous post of this present discussion :
https://community.notepad-plus-plus.org/post/50425
So :
SEARCH
(?-s)^((?!.+@).+\R?)+
( to delete any bunch of consecutive lines, not containing an e-mail addressSEARCH
(?-s)^((?!.+@).*\R?)+
( to delete the empty lines, as well ! )REPLACE
Leave EMPTY
Notes :
-
These two regexes match any non-null range of lines, which does not contain, each, the
@
symbol -
Of course, if your caret is located somewhere between two e-mail addresses, it will catch, only, from current location till the last line before a line containing an e-mail address
-
With these syntaxes, you may use the step-by-step replacement, with successive clicks on the
Replace
button -
It does not mind the lack of a last line-break, at the very end of of the current file
Best Regards,
guy038
-
-
@pinuzzu99, @Peterjones, @alan-kilborn and All,
@alan-kilborn, you said :
And all this in a forum that isn’t about regular expressions, but rather Notepad++!
You’ve got a point, there !! @Scott-sumner felt the same way, in this post :
https://community.notepad-plus-plus.org/post/35723
Have a look, at the same time, to my reply and question :
https://community.notepad-plus-plus.org/post/35742
Again, I wonder if most of my answers are relevant, in this forum ? I mean, all this should be dealt with in a forum dedicated to regular expressions However, note that I specifically speak about N++ functionalities of our regex engine !
Ah, ah : that could be a government slogan : Too many regular expressions can seriously damage your health !
Cheers
guy038
-
I think some degree of discussion is quite fine and appropriate. People start out with some data, a need to do something to it, and a tool (our beloved N++). What else are they to do but ask (on a N++ forum) “how can I do this with N++?” And that’s totally fine.
And the “weirdness” of the N++ engine? Also a very good topic here.
But, yea, slogging thru a lot of posts of typical regex handholding gets old, and I agree with you that it is better on a regex dedicated site. Hopefully you are patrolling those as well and helping the rest of the world with regex! :-)
-
@pinuzzu99 said in delete line between bookmark:
greeting to all. closed.
You’ll probably not read this (or see Guy’s excellent reply), but for future readers of this thread, I have to make a couple more statements
I wasn’t sure that guy038 was answering me,
Because it took more than 12 hours!? For future readers: some problems take more than 30seconds to solve, and on non-live forums, it can take a day or two.
and since nobody was helping me here,
We were all helping you. And both Guy and I answered almost simultaneously today explaining exactly why replace all worked but replace (once) didn’t. If that’s not helping you, I don’t know what is.
Beyond that, we were helping you, explaining that in help forums, asking politely, not demanding immediate response, and showing an effort to learn is a much better way to get help.
I asked my question and not only as you say it has not been closed, but indeed they replied immediately
Well, the userbase of of Stack Exchange is probably a thousandfold more than this Community, so there are a lot more to draw from.
-
@guy038 tank you so much, your last string
(?-s)^((?!.+@).+\R?)+
work very well for my purpose! Regards.