How to create a remove "Search Mode: Regular expression"
-
Hello @red-orb, alan-kilborn and All,
I tried to guess ! May be :
-
(?-s)\{.+?\}
if the line{..............}
is not split in several lines -
(?s)\{.+?\}
if the line{..............}
may be split in several lines
Best Regards,
guy038
-
-
Hi @Red-Orb, @Alan-Kilborn, @PeterJones and All
Just guessing, but maybe @Red-Orb is looking for a simple regex to filter out —and here I am reading as literal as possible—
dashes
,blank spaces
, anyåÅäÖ
instance andnumbers
.If and only if I am not that wrong, then the following S/R regex may work for OP:
Search:
[-åÅäÖ \d-]
Replace:[leave empty]
String to process:
{Remove This - remove this and letters åÅäÖ numbers 1 2 3 4 5 6 7 8 9 0}
Output:
{RemoveThisremovethisandlettersnumbers}
Now, @Red-Orb, if this is not what you want, then please follow @PeterJones 's advice and help us to help you.
-
@astrosofista
Thanks for reply, appreciate it!Sorry for not explaining correctly…
Here is a screen dump and here is text:{This, and that, remove and replace including å Å ä Ä ö Ö numbers and ; : ? ! .
Sorry for bad explanation on what I’m trying to achieve.}Red
-
-
@Alan-Kilborn
Did you see the image?
I don’t know how to explain?
I have these lines with {} in a textfile and I want to remove the brackets {} and all text inside brackets [}.
I want to use a regular expression to remove them.
And… this seems to work
(?s){.+?}Thanks and best regards
Red -
@guy038
Thanks for your help! :D -
@Red-Orb said in How to create a remove "Search Mode: Regular expression":
Did you see the image?
Yes, it didn’t add any info AFAICT.
And… this seems to work
(?s){.+?}
Well, that is basically @guy038 's solution from before, which you hadn’t previously indicated that it did or didn’t work for you, or even if you tried it.
But since{
and}
have special meaning for regular expressions, @guy038 “escaped” them for use as a literal text match, using the syntax\{
and\}
.
It can work without the escaping, but it is a dangerous habit to get into. -
@Alan-Kilborn
OK! I’m trying to understand how I could explain in any other way than showing a screendump and in explaining text.
Can you understand now what I’m trying to achieve?
If you have any input on how to create a “safe” habit I would really appreciate it.Best regards,
Red -
@Red-Orb said in How to create a remove "Search Mode: Regular expression":
I have these lines with {} in a textfile and I want to remove the brackets {} and all text inside brackets [}.
At least to me, that’s an understandable explanation of your needs, and shows that I was way wrong. Bad luck :)
-
@astrosofista
Thanks! -
@astrosofista said in How to create a remove "Search Mode: Regular expression":
“I have these lines with {} in a textfile and I want to remove the brackets {} and all text inside brackets {}.”
At least to me, that’s an understandable explanation of your needs,Yes, that’s understandable, but with all the earlier extra information about specific unicode characters and digits, it was all open to wider interpretation.
If you have any input on how to create a “safe” habit
Well, it just comes from experience; in this case, experience with regular expressions.
And of course that comes from studying the docs. And practice and more practice.
This one was a strange case, because it does indeed work as if{
and}
have no special meaning. -
@Red-Orb said in How to create a remove "Search Mode: Regular expression":
how I could explain in any other way than showing a screendump and in explaining text.
You could read the advice I posted:
- include all text as text in your post, marked up using the
</>
button
- you could show the text you have before the search-and-replace operation, as well as the text you want after the search-and-replace operation
- when you do embed images (which are only necessary if there’s something in the graphics that will add clarity that the text doesn’t show, like highlighting), actually embed them using the image button from the same toolbar above
so that it shows up in your post, rather than making us click, like:
or, easier, for static images, just copy your screenshot into your clipboard, thenCtrl+V
to paste the image directly into your post without uploading to imgur. - Include examples of what to modify and what not to modify
All of that was stated above.
So, for your example, you could have said,
Hello, I have the text where I would like to delete everything between the curly braces, including the curly braces.
For example:this I want to keep {this I want to delete, even with numbers like 1 or other special characters like å Å} more to keep {more to delete} more to keep and even {delete a multi-line braced expression} something more
I would like to delete everything inside the curly braces
{...}
, including the curly braces themselves, so that it will look likethis I want to keep more to keep more to keep and even something more
In a few brief lines, that would have told us everything we needed to know – by giving examples both where the braces are alone on a line and examples where they are inline with other text, we could see your desired result, and know that you wanted to match even if
{...}
was embedded between other text, or when{...}
spans across multiple rows. - include all text as text in your post, marked up using the
-
@Alan Kilborn
Thanks and best regards
Red@PeterJones
OK! I’ll save this as a textfile and try to use your helpful info next time I need advice.
About using imgur I thought it would be better to upload than to use the clipboard as it was a large image?
Thanks and best regards
RedPS/
For reasons I cannot understand my earlier profile in here was deleted? -
@red-orb-0 said in How to create a remove "Search Mode: Regular expression":
About using imgur I thought it would be better to upload than to use the clipboard as it was a large image?
If you want to upload to imgur first, you may. I embedded your image, still housed on imugr, by clicking the button. That button inserted the text
![alt text](image url)
, withimgage url
highlighed. I pasted the imgur URLhttps://i.imgur.com/W8orl27.jpg
there so it became![alt text](https://i.imgur.com/W8orl27.jpg)
, and voila, the image was embedded here while still hosted at imgur.But pasting the image directly here, so the URL becomes something like
https://community.notepad-plus-plus.org/assets/uploads/files/1589468012401-7f628367-d23b-41ad-9b07-33a38ec32979-image.png
(my image button, above) means that all readers here will be able to see it; many of the regulars are checking here during their coffee breaks at work, or reading to get an answer they need to accomplish their job, but some IT departments block sites like imgur as not being work-related.my earlier profile in here was deleted?
No. @Red-Orb (https://community.notepad-plus-plus.org/user/red-orb) and @red-orb-0 (https://community.notepad-plus-plus.org/user/red-orb-0) are two independent accounts, but both still exist. Did you sign into one using google and the other facebook, or some such?
-
@PeterJones
I will keep all your helpful information on how to post correctly, I really apprecite your help! Thanks!
About my profile/account.
I have no idea what’s going on with login and user profile?
I only login using google and there’s the culprit I think?
Couldn’t login today again… ? Very annoying!
So I’m still the same Red Orb though and will try to figure out why google fails.
Best regards
RedEdit:
Is there a way to delete old profiles in here! May be a mod can do that? -
@redorbroder said in How to create a remove "Search Mode: Regular expression":
I have no idea what’s going on with login and user profile?
I only login using google and there’s the culprit I think?
Couldn’t login today again… ? Very annoying!I’m not sure what’s going wrong for you. I am always logged in using my Google account. Today, just to make sure, I logged out, then followed the login procedure again:
I logged in just fine.
My next thought would be that you have more than one Google account, but picked a different one each time… but g
Hmm… I tried opening the login page with an incognito, so it didn’t have me already logged into Google. Then when I click “sign in with google”, it says:
Here, you would enter your google account email, and click NEXT. If you click “Create account”, it will create a new account – so don’t do that. If you have multiple Community accounts created with the same Google account, I have no idea what the Community Forum software will do, how it would decide which to log in as.
Is there a way to delete old profiles in here! May be a mod can do that?
I don’t know whether that’s possible. @guy038 or one of the other moderators here might be able to help you. But I’d recommend figuring out your logging-in difficulties before deleting old accounts.
-
@PeterJones
Thanks for your help and info.
I’ll just leave the accounts as they are, don’t want to mess things up…
This account will be the one I use from now on.Best regards,
Red