How to remove middle text?
PeterJones last edited by PeterJones
Where are you all going? This is too much. Ah I don’t remember today is Sunday. Probably because of that, everyone is sunbathing with their lover No wonder no one found Help. I just have to sit and watch the computer screen.😴😴😴
Unbelievable. Just … wow. Those two posts were only one hour and fifteen minutes apart. Just how impatient are you?
This is not a paid support forum: we are all fellow users of Notepad++, who enjoy talking about Notepad++ and its capabilities; and some of us are willing to help others who have questions to learn to use Notepad++ to get the best experience possible. None of us are employees of The Notepad++ Corporation (which doesn’t exist), and you have not paid anyone here for immediate 24/7 support. Demanding instant responses will get you nowhere; do not expect instant answers on any such public forum, whether it’s 1pm on a weekday, or 1am on a weekend, wherever your physical location happens to be.
As @Alan-Kilborn and @astrosofista have pointed out, you seem to ask for us to do all the work for you, and you haven’t shown a willingness to learn. If you ever want useful help here again, I suggest reading and understand the following text. I hope you do try to learn the lessons from below. If you choose not to, I am sorry to say that you are not likely to get the answers to your questions, here or elsewhere. Good luck.
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 clipbpard to your post using
Ctrl+Vto 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.
@PeterJones Do not misunderstand my words. As I said earlier, my language would mean many different things if translated into English or another language. Sometimes it’s just as fun as what I said earlier, but if you translate it into another language, it’s a request or an order to get immediate assistance. I understand what you said, and I also know what this forum is for. I asked 2 more questions because the astrosofista did not explain to me the meaning of each regex. For example, \ K this symbol I first saw. Can you show me how rude I am at what I say in this forum?
PeterJones last edited by
Coming back 1.5 hours later asking why no one has responded is what seemed rude to me.
\K“resets” the search, so everything before the
\Kmust be matched, but won’t be included in the replace. Thus, everything thru the first colon
:in the regex will be kept, and everything after the
\Kwill be deleted. That way, it can be required to have text before the portion that will be deleted. (There are other ways to accomplish the same thing, too.)
The documentation that you have been linked to does explain this. It is written in English, but you should be able to use a translator on it and get the main points.
As I said in the italics section of my earlier post, the best way to get good answers is to show that you are making an effort. Show us example data, highlighted
as plain textusing the
</>button in the post-edit window, so that we know special characters are coming through correctly. Show us what you tried. Ask specific questions about the syntax if you want (Something like “please explain the meaning of
\Kin your expression” is a good question, for example).
The best way to learn regular expressions (regex) is to start using them – see what does and doesn’t match, give it different text to see how the behavior changes, and so on – and read documentation. Many regex engines use similar syntax, so if you find a good regex tutorial in your native language, it will help you get the concepts down, then you can go to the translated-from-English for our documentation for the specifics of the Boost regex engine used in Notepad++.
The more effort you show, and the better you ask your questions, the more the answers will help you.
@PeterJones Why do I have to study? Can you tell me the reason? “Coming back 1.5 hours later asking why no one has responded is what seemed rude to me” This is absurd !!! So if after 15 minutes or 5 minutes I keep asking? Will you lock my account or will you Kick Ban my IP? While I was talking to the other person and I kept asking questions related to the first question, was that wrong? Do you have a problem in your mind? If you feel me rude why are you still answering me? While the problem I need then you do not respond.
I want to delete the text at the end of my example but I don’t ask the \ K symbol. \K is my example to explain the reason to you.
@PeterJones My first question is to delete the middle text. And that person helped me with that. And then I went back and asked, if I want to delete the last or the first text, what should I do? Please check back. I do not ask a question repeatedly. I do not understand what I am wrong? Don’t say 1.5 hours and after 3 minutes I still have the right to ask questions here. If you think it is rude, then I think you need to get a medical examination.
guy038 last edited by
Why do I have to study ?
Well, I would say, as a joke, to become more intelligent and, more seriously, to make your work easier and more autonomous !
I really do not understand why you don’t want to invest a few days of your life to learn the basics of regex’s syntax. After this short period of learning, it should be useful to you , in your everyday work, without the need to get someone’s help ;-))
But, if you persist in your attitude, chances are no one will want to help you anymore !
@guy038 Thank you for letting me know about this. However, instead I studied this issue that I take the time to do things that other economic benefit of my family. Everyone is different circumstances. If you’re doing one work to care for family, whether you leave work every day then just to learn one topic does not help economic your family?
Please ignore problems that go, because it is not related to me, to you, and it is not related to the content of the forums about it. The problem here is that I need to know how to delete text at the bottom or at the top in my example stated:
And how to get this result ???
And this result ???
This post is deleted!
Mary Soifaite last edited by Mary Soifaite
I’ve used this one, and it worked for me. But there are still residual marks behind: in each line. Is there another way?
Replace with : Blank
PeterJones last edited by PeterJones
Since the new “@Mary-Soifaite” participant is at least showing a little bit of effort, showing regexes that were tried, I will chime in again.
if I had text that was split up in three groups, using colon
:characters to separate the groups, and wanted to pick one or more of those groups, I would use a generic expression like
- FIND =
which puts the first term in $1, the second in $2, and the third in $3.
To make it clear, I will use the dummy text
as my example, though I know that any other characters than
:can be in each section
For the replacement, depending on which words I wanted to keep, I would use
- REPLACE =
But whether your name is @Mary-Soifaite or @Sarah-Duong or @PeterJones or @guy038 , the way to learn how to do these things yourself, rather than asking every time and getting impatient when volunteers don’t answer you right away is to spend a few minutes reading the documentation. If it’s important enough to spend time writing up the question, and it’s important enough to spend time writing a response complaining that volunteers don’t reply within 10 minutes of asking the question, then it’s important enough to start learning to do on your own; and the way to do that is to learn from the examples that @Sarah-Duong has already been given in multiple discussions on this forum, and to read the documentation that has been linked in multiple conversations with @Sarah-Duong.
@Sarah-Duong: to get good answers
Show patience: Based on your native language, I am assuming you are in Asia; Guy is in Europe; I am on the West Coast of the United States. Local time is different for each of us. The person who may be best suited to answer your question may not be around during a time that is “convenient” for you. Some of us are here on our local weekends; some are here on our local weekdays; some are here just in our local evening; some come frequently; some come only occasionally. Waiting an hour or two, or a day or two, or even a week for an answer here are all perfectly-reasonable response times. If you complain about how long it’s been (“Where are you all going? This is too much.”), it is annoying to those of us who volunteer our time to help others in the forum. We are not paid for this. We all have other things – family, paying jobs, hobbies – in our lives that compete for our time.
Show an effort, show a willingness to learn: that includes making use of what we’ve shown you before, trying to slightly change things as circumstances change; ask questions about why something does or doesn’t work; don’t just tell us “and now, in this other circumstance, give me the answer”. Show what regex you tried: I appreciated that “@Mary-Soifaite” at least posted a regex that had been tried; she didn’t say why she thought it would work, and because she didn’t use backticks like
`([a-zA-Z0-9.%+-]+@`, we cannot actually tell what her real regex looked like… but she at least showed something she tried: it shows an effort
If you feel me rude why are you still answering me
Because I want you to learn. The only reason I have hung out in this forum for the last four and a half years is because I like helping other people learn how to use this tool. And every once in a while, even in this discussion, you show that you might be willing to learn. You have spent a lot of time in this discussion arguing, and in this and other discussions, you tend to want us to just hand you the answer… but I haven’t given up, and I keep hoping that with the right phrasing, you’ll start asking better questions, and start learning from all the effort we have put into helping you.
- FIND =
guy038 last edited by guy038
I think that we can generalize the @peterjones’s search regex to any number of fields, with a
So, let’s suppose that each line of your table contains
N + 1fields, from
string_0:string_1:string_2: ....... :string_N
Then the generic regex, below, should work to get, after replacement, any group
^([^:\r\n]+):((?1)):((?1)): ...... :((?1))
Ntimes the regex
So, @mary-soifaite, assuming your example :
the search regex
^([^:\r\n]+):((?1)):((?1))and one the
3replacements, proposed by Peter, should work just nice ;-))
[^:\r\n]represents any standard character, different of a colon
So, the pattern
[^:\r\n]+stands for a non-mull range of this character
Now, the repeated pattern
(?1)is a sub-routine call to group
[^:\r\n]+). So, a reference to the regex itself and not the present value of group
As each sub-routine call is surrounded by a couple a parentheses, each of them are referenced as group
3, and so on … till group
Actually I do not know how to start. Here is my file, I copied one section to let people be able to understand and visualize the problem.
I don’t post it here. It report error.
Mary Soifaite last edited by Mary Soifaite
and I need to get the results:
hope people understand my
guy038 last edited by guy038
Thanks for your different images. And, this confirms that, if we consider the general template :
You’re expecting two lists :
STRING_1:STRING_2, so, the first two fields
STRING_2:STRING_3, so, the last two fields
The former list should be obtained with this regex S/R :
The later list should be obtained with this regex S/R :
^([^:\r\n]+):((?1)):((?1))( idem as above)
Of course, you must select the
Regular expressionsearch mode, tick the
Wrap aroundoption and, finally click on the
Replace Allbutton !
Note that, instead of posting some images via an other site, you could have simply pasted the clipboard contents of your text, directly in your post area, by using the usual
Ctrl + Vshortcut : it’s easier for people to test regexes against your data
Even better : before pasting your text, click on the
</>button, first, in order to insert code text !
Thomas 2020 last edited by
it can also be so