delete line between bookmark



  • @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 YOU

    Wow, 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 the Replace 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, the F3 key for next search and so on…

    Note that pressing the Delete key is a one-step operation, just like a single click on the Replace 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 address

    SEARCH (?-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



  • @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.


Log in to reply