Need help please
-
Say for example I have this
1111:55555:8383:jjjsyn:ayahj:jsjsja:jjsjjsjjs
6262g:yysh:ysyahj:hjjma:ksksygg:jsjjsj:jsjjsjzI want to delete this character “:” but not all just the first one so the results become like this:
111155555:8383:jjjsyn:ayahj:jsjsja:jjsjjsjjs
6262gyysh:ysyahj:hjjma:ksksygg:jsjjsj:jsjjsjzThank you.
-
Reference HERE.
-
@Alan-Kilborn
At least you can help me on this because It’s urgent, I did learn a lot but whenever I need help I should ask the community here? I can’t learn everything and I’m not a lazy person. -
The post he pointed you to gives an answer to a nearly-identical problem that you previously posted. What part of the problem seems significantly different to you this time, compared to the previous question, that means you could not apply the concepts you learned the last time to this time?
(And your sense of urgency is irrelevant to us. We’re all just fans and users of Notepad++, and some of us choose to spend some of our free time helping other Notepad++ users. Your $0 investment in Notepad++ does not guarantee that you will get instant 24/7 support from other users of Notepad++.)
----
Useful References
- Please Read Before Posting
- Template for Search/Replace Questions
- Formatting Forum Posts
- Notepad++ Online User Manual: Searching/Regex
- FAQ: Where to find other regular expressions (regex) documentation
----
Please note: This Community Forum is not a data transformation service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and new to regular expressions, we will often give help on the first one or two data-transformation questions, especially if they are well-asked and you show a willingness to learn; and we will point you to the documentation where you can learn how to do the data transformations for yourself in the future. But if you repeatedly ask us to do your work for you, you will find that the patience of usually-helpful Community members wears thin. The best way to learn regular expressions is by experimenting with them yourself, and getting a feel for how they work; having us spoon-feed you the answers without you putting in the effort doesn’t help you in the long term and is uninteresting and annoying for us.
-
@PeterJones
With all due respect, the reference post had nothing to do With this post, I certainly can’t apply the same regx and they are Two opposite things. I posted this so that someone can help me fix it because I couldn’t find it Someone else.
I appreciate the work you’re doing and I understand that you’re doing it for free and I’m not here to argue I just need help, I use notepad++ every day And I’m definitely learning. -
@Wahlla-Magla said in Need help please:
With this post, I certainly can’t apply the same regx and they are Two opposite things.
As has already been pointed out to you, this question is nearly identical to the previous one referred to. The solution provided there has the makings of a solution for you here.
Use the website www.regex101.com, insert the previous solution and read the explanation for it. Start editing that solution (I’d suggest removing portions of it) to see what it then does.
If, as you say, you learned a lot you have the ability to solve this yourself. Give it a go. If you show some work, even if it’s wrong you will get far more support here, than just harping on about the urgency.
Terry
-
@Wahlla-Magla said in Need help please:
@PeterJones
the reference post had nothing to do With this post, I certainly can’t apply the same regx and they are Two opposite things.The same regex – of course not. I never said you could. But it has the same concepts. And I will prove that below.
I posted this so that someone can help me fix it because I couldn’t find it Someone else.
I appreciate the work you’re doing and I understand that you’re doing it for free and I’m not here to argue I just need help, I use notepad++ every day And I’m definitely learning.You posted this so that we’d do your work for you. And you got it again this time. Lucky you. But if you haven’t figured out the concepts of the previous regex in the more-than-1.5-years since that last post, it’s really hard for us to believe you are really here to learn instead of trying to guilt us into doing your work for you.
So here is a description of the concepts that Alan’s regex from 2021 should have taught you, and an exaplanation of how the concepts that were presented in your previous question are exactly the same concepts you are still working with here – at the same time, giving you the answer you wanted to this specific problem.
In the previous post, you had some colon-separated text
item:email:item:password:item:item:item:item:item:item:item:item:item
and wanted to do something with text between the colons, but only specific fields.
In this post, you have colon-separated text
1111:55555:8383:jjjsyn:ayahj:jsjsja:jjsjjsjjs
and want to do something with the text between the colons, but only for specific fields.
In the previous post, the search
(?-s)^.+?:(.+?):.+?:(.+?):.+
grabbed the second and fourth fields from your colon-separated text, and${1}:${2}
did the replacement so everything was replaced with just groups#1 and #2 (which were your second and fourth fields) with a colon betweenThis time, what you want is to grab the text from the first and second fields, and replace it with the same text, but with no colon between.
So the concepts involved:
- you want to start at the beginning of a line, so that you know which field you are in at any point in the regex – this was true of both. You do this with the
^
anchor - you want to be able to temporarily store the contents of one or more of the fields – this was true of both. As Alan showed you in 2021, you do this by the
(.+?)
sequence - you want to split the fields based on the colon – both last time and this time. Using the
:
in the regex in the right places does exactly that. - you want to replace some or all of the line with the contents of groups you saved – you wanted this before, and you want it this time. The difference is that before, you wanted to replace the whole line with those contents, and this time, you only want to replace part of the line with those contents.
So to evolve the old regex into the new:
- The groups you care about are the first and second instead of the second and fourth. So that will change the regex from
(?-s)^.+?:(.+?):.+?:(.+?):.+
to(?-s)^(.+?):(.+?):.+?:.+?:.+
- You don’t want to affect anything after the second colon from the original text. So that will mean you don’t need to continue the match beyond the second colon in the regex, so just trim it down:
(?-s)^(.+?):(.+?):
– now it just matches the first two fields and the colons that follow them. (I included the second colon to help anchor things) - You want to replace that smaller matched section with the contents of the groups, and (since I included the trailing colon) a colon after, but no colon between. So you take the original replacement from the previous discussion,
${1}:${2}
, which put a colon between the group#1 and group#2, and instead just want the two groups together with a colon after, like${1}${2}:
In the end, you end up with
- FIND =
(?-s)^(.+?):(.+?):
- REPLACE =
${1}${2}:
with just a couple of quick changes to the previous regular expression
With initial text
1111:55555:8383:jjjsyn:ayahj:jsjsja:jjsjjsjjs 6262g:yysh:ysyahj:hjjma:ksksygg:jsjjsj:jsjjsjz
and doing Replace All with the find/replace I showed above, I get
111155555:8383:jjjsyn:ayahj:jsjsja:jjsjjsjjs 6262gyysh:ysyahj:hjjma:ksksygg:jsjjsj:jsjjsjz
That is the text you said you wanted to get.
Thus, I have shown you that it was exactly the same concepts involved for breaking the line of text into fields, and exactly the same concepts involved for doing the replacement.
Stop lying to yourself: you can learn this, but you have to put in the effort to do so – and since you couldn’t see that it was the same ideas this time as last time, it shows that you haven’t put in the effort to understand. I’ve given you the blow-by-blow description for the slight changes necessary this time, in the hopes that you will start to see the concepts behind the regex, so that you can continue to customize those same ideas next time.
- you want to start at the beginning of a line, so that you know which field you are in at any point in the regex – this was true of both. You do this with the