How to delete "(....)" but only in certain lines
-
Thanks but this code also replaces the (…) from the descriptions
-
@imgema ,
Not if you followed the directions in the post I linked you to. FR doesn’t go by itself in the Find box; there are other pieces that are required for the logic to work.
But that other post explains exactly what you need to do: You have to figure out what the BSR, ESR, and RR need to be for your circumstances – it’s pretty easy to do, since those are just the “begin” and “end” conditions for which sections you want to include (I’ll give you a hint: those values will look a lot like XML tags), and since you want to replace it with nothing, I think RR will be obvious. Once you have figured out what those values need to be, you have to look at the expression that Guy supplied in that post I linked you to, and type those values instead of FR, BSR, ESR, and RR in the Find/Replace boxes.
-
@peterjones
I’m sorry, this is over my head. I don’t know what these FR and BSR words mean.I was looking for a code to use as is.
-
@imgema said in How to delete "(....)" but only in certain lines:
I’m sorry, this is over my head.
It can’t be, this is your data you need to manipulate.
I don’t know what these FR and BSR words mean.
Did you even read the linked posting?
It’s all right there.I was looking for a code to use as is.
Sure, I wish I had someone to do all my work for me, too.
-
Not really my data, i don’t know how to code, i’m trying to modify a xml that was generated by a program.
Thanks anyway, i’ll try to maybe figure it out then.
-
@imgema ,
Remember the old adage, “Give a man a fish, feed him for a day; teach a man to fish, feed him for a lifetime”? I was trying to teach, rather than than give. Sorry.
Here are the steps I was hoping you would be able to figure out.
Step 1: Read the post I linked you to.
Step 2: find the formula I mentioned- Let FR (
Find Regex
) be the regex which defines the char, string or expression to be searched - Let RR (
Replacement Regex
) be the regex which defines the char, string or expression which must replace the FR expression - Let BSR (
Begin Search-region Regex
) be the regex which defines the beginning of the area where the search for FR, must start - Let ESR (
End Search-region Regex
) be the regex which defines, implicitly, the area where the search for FR, must end
Then, the generic regex can be expressed :
SEARCH(?-i:
BSR|(?!\A)\G)(?s:(?!
ESR).)*?\K(?-i:
FR)
REPLACE RRStep3: Figure out what FR should be: I gave you this already:
\h?\(.*?\)
Step4: Figure out what BSR should be: I gave you hints already:<name>
Step5: Figure out what ESR should be: I gave you hints already:</name>
Step6: Figure out what RR should be: I think this is obviously the empty string
Step7: plug those back in:- 7a: plug FR into the expression:
(?-i:
BSR|(?!\A)\G)(?s:(?!
ESR).)*?\K(?-i:\h?\(.*?\))
- 7b: plug BSR into the expression:
(?-i:<name>|(?!\A)\G)(?s:(?!
ESR).)*?\K(?-i:\h?\(.*?\))
- 7c: plug ESR into the expression:
(?-i:<name>|(?!\A)\G)(?s:(?!</name>).)*?\K(?-i:\h?\(.*?\))
- 7d: type that final expression from 7c into the FIND box
Step8: type the RR expression (the empty string) into the REPLACE box
Step9: check the Regular Expression box
Step10: click Replace AllIt works:
BEFORE:
AFTER:
- Let FR (
-
Thanks for the guidelines and solution. I appreciate it.
-
Hi, @peterjones, @alan-kilborn, @terry-r, @astrosofista and All,
As I reported in the second part of this post :
https://community.notepad-plus-plus.org/post/74410
and with further explanations in this one :
https://community.notepad-plus-plus.org/post/74418
I suppose that we would take avantage to adopt the @hellena-crainicu syntax
(?!^)
( instead of(?!\A)
) !BR
guy038
-
@guy038 said in How to delete "(....)" but only in certain lines:
I suppose that we would take avantage to adopt the @hellena-crainicu syntax (?!^) ( instead of (?!\A) ) !
So how about adding that in the canonical posting linked above; this one to be specific:
https://community.notepad-plus-plus.org/post/62799
Please DON’T edit that posting, because a lot of things already like to that, and editing it now would make it confusing. Add a new post in that owner thread, with the updated technique. OR, maybe some brand new thread?
-
@alan-kilborn said in How to delete "(....)" but only in certain lines:
OR, maybe some brand new thread?
I would second the brand-new-thread suggestion. That way, it doesn’t have the confusing context of a specific question with details that don’t match the person’s that we’re pointing to the post. (it goes back to my Developing generic regex sequences from last year, where I wanted to allow us to develop the generics in that thread, then when they were ready, spawn each generic off to a separate “official” topic, and maybe have a post in the FAQ that links to the “official” version)
-
Hello, @peterjones,
After further testing, I came to the conclusion to keep the present syntax
(?\A)
. Refer to this post for some explanations :https://community.notepad-plus-plus.org/post/74937
So, sorry for the noise. I’m going to reformat most of my notes, concerning this specific regex.
Then I will send it to you by mail for checking before finding a final destination for it !
Cheers,
guy038
-