Replace help
-
How do I remove the parentheses from a whole list of things like this:
A Song of Ice & Fire (2010)
I would prefer to remove the space between fire and ( as well?
-
I have a similar goal. I have a long list of numbers and would like to remove the square brackets from around the number “[ ]” so only the numbers remain:
Source looks like this:
[8846262],
[8846277],
[8845984],
[8846001],
[8845614],
[8845628],
[8845297],
[8845308],
[8844920],
[8844926],
[8844580],
[8844588],
[8844377],
[8844381],
[8843972],
[8843980],
[8843715],
[8843728],
[8843290],
[8843300],End goal:
8846262,
8846277,
8845984,As you can see there is also a space in front of the first bracket.
Using " [[^]]+] " removes everything within the brackets. I need the numbers to stay.
.[ - finds all the initial brackets and I can insert a line break then do the same with the end bracket but I’m looking for a more elegant solution.
:)
Thanks,
Szabolcs -
This post is deleted! -
I need to remove the numbers in the parentheses as well. I may try your solution to see if it works for me.
-
Your problem statement is hugely ambiguous. If you want help, it’s generally best to supply enough information for us to understand your question, let alone answer it.
Based on your original problem statement, I would have said
- FIND =
\h*\(|\)
- search for 0 or more spaces followed by a
(
, or search for)
- search for 0 or more spaces followed by a
- REPLACE = blank/empty
- replace with nothing
- SEARCH MODE = regular expression
Starting from
A Song of Ice & Fire (2010) Some title hear (year) Blah (blah)
This would give
A Song of Ice & Fire2010 Some title hearyear Blahblah
… which is nonsense, but matches the description you gave in your original post
However, this comes close to meeting @Szabolcs-Horváth’s problem statement… which is slightly better, because he at least showed “before” and “after” data. For @Szabolcs-Horváth , though, since he doesn’t need the space removed, I would simplify to a character class, such as
[\\[\]]
which means find either the literal[
or the literal]
and replace with nothing.With your (@Tco-Robinson’s) added caveat of “I need to remove [what is] in the parentheses as well”, it becomes a completely different problem than you originally described, with a different solution:
- FIND =
\h*\(.*?\)
- find 0 or more spaces, followed by literal parentheses with anything inside)
- REPLACE = empty/blank
- SEARCH MODE = regular expression,
- Make sure . matches newline is turned off
This will convert the original data set I showed to
A Song of Ice & Fire Some title hear Blah
which might be closer to what you want.
However, since you specifically said “year”, then maybe you don’t want non-numerical contents of parentheses to be deleted. if that’s the case, change FIND WHAT to
\h*\(\d{4}\)
, which searches for 0 or more spaces, a literal(
, exactly four digits, and a literal)
, which will convert the original data toA Song of Ice & Fire Some title hear (year) Blah (blah)
… so the text inside parentheses stays there, but the year (four-digit number) in parentheses goes away.
Do you see how useful it is to actually include examples of things that do and don’t match, and to show both before and after data? It makes your problem much easier to understand, because then I could have presented just one of my three solutions, rather than having to come up with all three, or having to drag the information out of you to narrow it down.
I am posting useful advice below. If you do not show that you have read and understood this advice, by following this advice in any future response, you will find that any help you might get will likely not meet your needs (and the help will not be from me, if you don’t act on the advice given). If you want good help, you have to give enough information for us to help you.
----
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. - FIND =