help to delete part of line



  • i have:

    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/3608901" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-001</a><a href="/browse/artist/9132212" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-004</a><a href="/browse/artist/6442260" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-006</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/135009754" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/7977697" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-002</a><a href="/browse/artist/15485966" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-005</a><a href="/browse/artist/9132212" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-007</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/140277082" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/5976891" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-009</a><a href="/browse/artist/22432468" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-008</a><a href="/browse/artist/4679991" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-011</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/253546781" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    

    and i need:

    Artist-001 Artist-004 Artist-006
    Artist-002 Artist-005 Artist-007
    Artist-009 Artist-008 Artist-0011
    

    value change on artist/xxxxxxx (repeated times) and album/xxxxxxx at the end of each line.
    i’ve try this

    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/.*." class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>
    

    but this command delete all value up to the last Artist value…
    how to delete all character except various values Artist?
    tanxs to everybody for your help!



  • Hi @cisco779k

    I would try an alternation, just to get ride of the trailing chars:

    Search: .+?(Artist-\d+)|.+$
    Replace: ?1($1\x20)
    

    Put the caret at the very beginning of the document, select just the Regular Expressions mode and click on Replace All.

    Have fun!



  • This post is deleted!


  • mmm… work on this example, but (my error) i have my list with little difference:
    i have above each line, a text that i want to keep (i didn’t think it would affect the command, sorry!)
    i have:

    text 9384839
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/3608901" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-001</a><a href="/browse/artist/9132212" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-004</a><a href="/browse/artist/6442260" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-006</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/135009754" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    text 9304543954
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/7977697" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-002</a><a href="/browse/artist/15485966" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-005</a><a href="/browse/artist/9132212" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-007</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/140277082" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    text 35723732847
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/5976891" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-009</a><a href="/browse/artist/22432468" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-008</a><a href="/browse/artist/4679991" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Artist-011</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/253546781" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    


  • Hi @cisco779k

    I would have expected your new attempt, after all the solution is not that hard, just a variation of the previous post. Anyway, the new S/R expression could be as follows:

    Search: <.+?(Artist-\d+)+|.+>$
    Replace: ?1($1\x20)
    

    Have fun!



  • @astrosofista

    I would have expected your new attempt

    Takers gotta take.
    Givers gotta give.
    It would be better if the givers would be more united and make the takers try (or go without a solution).

    But I wouldn’t have posted just to say the above.
    I’m posting to say that if you use a . in your solution, you really also should use (?-s) or (?s), as appropriate, because we have no way of knowing a user’s . matches newline checkbox.



  • Hi @Alan-Kilborn

    Good point ! in my defense I would argue that those were pre-coffee solutions :) - Anyway, I never use the . matches newline checkbox, so it is out of my radar.

    Have fun!



  • very tanxs for your reply.
    but your regex work fine with my post above but not work with my real txt…
    i’m pretty sure i edited it correctly but maybe i’m wrong (yet) something. so i’m forced to write here a part of the real txt

    AEIOU
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/4192063" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Wye Oak</a><a href="/browse/artist/8621995" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Brooklyn Youth Chorus</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/145454837" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    My Rajneesh
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/64638" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>Sufjan Stevens</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/142313914" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    Guilty Conscience
    <!----></a></p> <p class="artist-list ellipsis margin-0" data-v-5f039afd><!----> <a href="/browse/artist/7703086" class="text-dec-none visible-offset-0 artist-list-link hover-desktop" data-v-5f039afd>070 Shake</a></p> <!----></div> <div class="col-4 col-md-4 col-sm-4 flex-grow track-additonal-info margin-0" data-v-5f039afd><p class="ellipsis" data-v-5f039afd><a href="/browse/album/127154171" class="text-dec-none visible-offset-0 hover-desktop" data-v-5f039afd>
    

    and i need to have this:

    AEIOU Wye Oak Brooklyn Youth Chorus
    My Rajneesh Sufjan Stevens
    Guilty Conscience 070 Shake
    

    i thought it was easier… i don’t want you to waste too much time. in the case of no answer i can understand that i asked too much, and so it is fine even so.
    a greeting



  • You´re welcome. It is not a good sign to change the target on every post, because there is no chance to solve the problem. And it’s a waste of time.

    As I now understand the question, the text enclosed with angle brackets doesn’t matter anymore, but the free sentences. So, the point is to resort to a destructive regex, selecting the text between angle brackets -and only that- and then delete it - that is, leaving the replacement field blank.

    Now is your turn. The search regex is quite simple, you can take into account the one proposed in my previous post. Good luck.



  • @cisco779k ,

    As a reminder, the quality of answers you receive is directly proportional to the quality of question you ask.

    I understand that in some circumstances (when manipulating data at work, or when your at-home data contains sensitive information), people asking questions have to edit their data so that sensitive, private, etc information is not included. But the names of Artists and Albums is not sensitive or private, so it was just a waste of our time for you to have hidden that. If you do try to hide data, you need to make sure that you don’t add artificial “rules” or “keywords” that you don’t intend.

    When @astrosofista and @Alan-Kilborn (and I) have been reading your posts, we have all assumed that the literal text Artist- is present in the field that you wanted us to keep. Now, only after 8 messages back and forth, with solutions that worked with your example data, do you suddenly reveal that Artist- was just dummy data and not literal text that you expected to be there, and that you were really looking for any arbitrary text contained in there. Without that simple trigger of Artist- being always present, the resulting regex will have to be extremely different.


    linguistic aside: “tanxs” is not an English word. It is obviously meant to say “thanks”, but it always triggers associations of baby talk or intentional laziness in my mind when I read it. If one of those are what you were trying to portray, then fine; if not, then please note that it can give that impression, and you might want to modify your communication style.

    This is your third regex question in a little more than a week, and in none of them have you ever shown an indication that you are actually trying to develop your own regular expressions or figure it out yourself before you ask us to do your work for you. As other helpers notice, they will be less likely to answer – as @astrosofista just indicated.

    Encoded base64 solution based on your newest requirements. All the tools you need to figure this out are included with a default Notepad++ installation, so if you put in a bit of effort, you’ll get this one last freebie.

    U2luY2UgaXQgbG9va3MgbGlrZSB3aGF0IHlvdSByZWFsbHkgd2FudCBpdCB0byBkbyBpcyB0byBtZXJnZSB0aGUgcGxhaW50ZXh0LW9uLWEtc2luZ2xlLWxpbmUgd2l0aCB0aGUgc3Vic2VxdWVudCBsaW5lLCBhbmQgc3RyaXAgb3V0IGFsbCB0aGUgSFRNTCBhbmQganVzdCBsZWF2ZSB0aGUgcGxhaW4gdGV4dCB3aXRoIHNwYWNlIHNlcGFyYXRpb24sIEkgd291bGQgc3VnZ2VzdA0KKiBGSU5EID0gYFxSKzwhLS0tLT58PC4qPz5gDQogICAgKiBpZiB0aGVyZSdzIGEgbmV3bGluZSBmb2xsb3dlZCBieSBgPCEtLS0tPmAsIGRlbGV0ZSB0aGUgbmV3bGluZSBhbmQgdGhlIGNvbW1lbnQtdGFnLCBiZWNhdXNlIHRoYXQgd2lsbCB0aGVuIG1lcmdlIHRoZSBzdGFuZGFsb25lIGxpbmUgd2l0aCB0aGUgbGluZSBhZnRlciBpdA0KICAgICogaWYgdGhlcmUncyBhbnkgb3RoZXIgaHRtbCBvcGVuIG9yIGNsb3NlIHRhZywganVzdCBkZWxldGUgaXQuDQoqIFJFUExBQ0UgPSBlbXB0eQ0KKiBNT0RFID0gcmVndWxhciBleHByZXNzaW9uDQo
    

    Good luck in further questions. I hope you start showing a willingness to learn and try.

    The boilerplate below will help you ask your question better next time.

    ----

    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 plain text using the </> toolbar button or manual Markdown syntax. Screenshots can be pasted from the clipboard to your post using Ctrl+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.



  • I have no idea how to get what I would like, otherwise I would post my evidence here. and I don’t have time to start studying for something like this.
    having said that, if anyone who knows has time to lay his code, well, I thank him.
    otherwise, I can understand that it is wasted time for you, but instead of making polemics you are simply begged not to post anything.
    In turn I help other users in other forums, but I have never asked them questions about the time I lose to help them. I do it because I have the desire and the knowledge to do it, if I do not know how to do it I do not answer, nor do I start talking to them “about the time they made me lose”…
    having said that I greet you and I thank those who, without much controversy, have previously answered my question



  • and I also hope that this time my writing is correct… is ever that someone does not understand a tanxs with a thank you…



  • This post is deleted!


  • @cisco779k,

    I am sorry if you felt attacked.

    I’ll just give you the answer that I obfuscated above. This works with your example text. I make no guarantee about your whole file.

    ----
    Since it looks like what you really want it to do is to merge the plaintext-on-a-single-line with the subsequent line, and strip out all the HTML and just leave the plain text with space separation, I would suggest

    • FIND = \R+<!---->|<.*?>
      • if there’s a newline followed by <!---->, delete the newline and the comment-tag, because that will then merge the standalone line with the line after it
      • if there’s any other html open or close tag, just delete it.
    • REPLACE = empty
    • MODE = regular expression

    ----

    I will do my best to avoid responding to you in the future. If you want to help me not reply to you, then I ask that you don’t change your username or create a new login, because otherwise I might be tempted to try to answer that new name for the same person.

    Good luck.



  • beyond your regex (which I will now try) I thank you for understanding my thoughts.
    I don’t understand why you say that in the future you would like to avoid answering… perhaps to avoid controversy. That is whether that is the reason, I repeat, there is no point in making polemics.
    but if instead you want to help me or others who present similar problems, I believe that every advice is welcome by anyone.
    so why avoid help (or answer) if you know how to do it and someone here asks for help? I think helping each other is a good thing.
    as far as I’m concerned your future responses to my posts will always be welcome.
    greeting and thank you for your help.



  • your regex work fine.
    thank you for your support.



  • @cisco779k said in help to delete part of line:

    beyond your regex (which I will now try) I thank you for understanding my thoughts.
    I don’t understand why you say that in the future you would like to avoid answering… perhaps to avoid controversy. That is whether that is the reason, I repeat, there is no point in making polemics.
    but if instead you want to help me or others who present similar problems, I believe that every advice is welcome by anyone.
    so why avoid help (or answer) if you know how to do it and someone here asks for help? I think helping each other is a good thing.

    I think the problem is that this isn’t a regex site, and continual back and forth about typical data conversions isn’t very interesting to those that participate here. If that’s what you’re looking for, then perhaps try to find a support site that strictly deals in regex; they would probably welcome your problems there with open arms, and give you as many solutions as you want.

    We want to talk about Notepad++, and while regex is a part of Notepad++, what we want to do with it is get people interested in solving their own problems with it, not continually just offering up solution after solution to those that don’t care to put in the effort to learn.

    So, while we’re all about helping someone “get started”, I think those are the roots of the story…



  • Hi, @cisco779k, @astrosofista, @alan-kilborn, @peterjones and All,

    The @peterjones’s regex S/R, below, works fine !

    SEARCH (?-s)\R<!-+>|<.*?>

    REPLACE Leave EMPTY

    However it remains some additional space characters !


    Also, in addition, here are two regex S/R to manage space and tabulation characters, in any situation :

    The first one :

    • Do not change any leading space or tabulation characters

    • Replaces any consecutive range of space or tabulation chars, between words, with a single space char

    • Deletes all trailing blank characters

    SEARCH (\h+)$|^\h+(*SKIP)(*F)|\h{2,}|\t

    REPLACE ?1:\x20


    If you prefer, also, to delete the leading space or tabulation chars, use this second one :

    SEARCH (^\h+|\h+$)|\h{2,}|\t

    REPLACE ?1:\x20

    which :

    • Trims all leading and trailing blank characters

    • Replaces any consecutive range of space or tabulation chars, between words, with a single space char

    Best Regards

    guy038



  • @ guy038
    thank you very much for your help, always much appreciated

    @ Alan Kilborn
    you’re right, I think this isn’t the right section to ask for these things. but I didn’t find a better section to post to, nor even a specific site to discuss regex… do you have any suggestions?
    and not getting any better (since here for many of you are simple things) I thought you ask for help here, waiting for suggestions on other sites/specific sections…



  • and while i’m still here, i take advantage of it (again!) to ask another topic:
    how can i put a bookmark only on even lines of a list?
    or how to delete even lines in a list?
    or even: can i put a bookmark only on specific ranges of lines? (even ones, in my specific case)


Log in to reply