help to delete part of line
-
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!
-
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. -
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 txtAEIOU <!----></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.
-
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 thatArtist-
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 ofArtist-
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 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. -
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! -
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.
- if there’s a newline followed by
- 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.
- FIND =
-
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) -
@cisco779k said in help to delete part of line:
bookmark only on even lines of a list?
I’m not on a PC as it’s late here, but here is a possible solution which is achievable for someone with limited regex experience.
As you say a list, that presumes it is part of a file rather than all lines, although my idea works for both.
- Select the lines if some of the file or put cursor in first position of file if all lines.
- Use the column editor to insert numbers, starting with 1, increase by 1, and set repeat to 1 (might need to be 2 , I haven’t used this option). No need to have leading zeroes but we do want each number listed twice.
- Create a regex which looks at a number and also the one on the next line. If both the same then delete the one on the odd line, which is most likely the first one.
- Once every 2nd number removed, use the bookmark feature to mark the (even) lines which have a number at the start.
- Remove the numbers at the start of the line.
Terry
-
Hi, @cisco779k, @astrosofista, @alan-kilborn, @peterjones, @terry-r and All,
EDIT : In this post, I’m answering, specifically, to the @cisco779k’s question : how to delete even lines in a list?
Ah ! Interesting problem ! Here is a nice regex solution :
SEARCH
(?-s)(.*\R).*\R?
REPLACE
\1
IMPORTANT :
-
The current line, even empty, becomes, by default, the virtual line
1
, whatever the cursor location. So :-
This virtual line
1
is kept -
The virtual line
2
is deleted -
The virtual line
3
is kept
-
and so on…
-
By default, the regex S/R processes all lines till the very end of current file
-
If you want to restrict to a specific range of lines, simply use the
In selection
option of the Replace dialog -
Beware to not perform this regex S/R, using the
Find in Files
search tab or using theReplace in All Opened Documents
button ;-) -
True empty lines are considered as valid lines, too !
-
You may record this regex S/R as a macro
Test this regex S/R against that list of features and bug-fixes of the
v7.9.1
change.log file !1. Fix NUL file-corruption bug after Windows shutdown brutally (Fix #6133). 2. Fix inaccurate URL detection by replacing a new URL parser (Fix #3912, #3353, #4643, #5029, #6155, #7791, #8634) 3. Fix RegEx look behind operations and \A and and \b and \z (Fix #713, #1870, #2216, #2360, #9004, #4855). 4. Split functionList.xml into multifile in "functionList" Folder (Implement #4896). 5. Make tray icon work again in administrator mode (Fix #8528). 6. Fix dialogs & floating dockable panels don't minimize to system tray issue (Fix #9044, #8928). 7. Add alternative icon set for tab bar (Implement #8068). 8. Add ability to remove any duplicate lines in a document, keeping the first occurrence (Fix #8965). 9. Fix incorrect icon for monitoring status in Document list panel and in Document switcher (Fix #8783). 10. Add copy marked text & styled text to clipboard commands to menu (Implement #8943, #6095). 11. Fix find-all-open-docs not finding all matches in ANSI files (Fix #8901). 12. Display long lines better in Find-result panel by increasing its max length to 2048 (Fix #7723). 13. Fix double clicking on find result line not working (Fix #9009, #8525). 14. Fix Find-result rclick-Copy incomplete data bug (Fix #8801). 15. Add case insensitive lines sorting (Implement #4479). 16. Add "Open Containing Folder as Workspace" command in main menu and in context menu of tabs (Implement #3028). 17. Enhance Sel info of status bar (Fix #8524). 18. Add new option for save type of normal text files in Save dialog (Fix #8866). 19. Fix file path truncated issue in save confirmation dialog (Fix #8812). 20. Fix auto-Indent not working for PowerShell (Fix #9049). 21. Allow setting of background color for bookmark margin (Fix #8833). 22. Fix smart-highlighting not applying to cloned view (Fix #7910). 23. Fix smart highlight issue related to EOF (Fix #8908). 24. Fix closing file in 2nd view not removed from Doc Switcher (Fix #8800). 25. Add Delete keystroke to remove selected root from Folder as Workspace (Fix #8960). 26. Add TAB keystroke in Function List to switch between search field and list (Fix 8665). 27. Add ESC keystroke in Function List to switch to edit window (Fix #8886). 28. Add ESC keystroke to close Search Results Window (Implement #2946). 29. Fix data-prefixed attributes are not recognized in HTML (Fix #6200).
Best Regards,
guy038
-