getmusicbee.com

Support => Questions => Topic started by: asdasdasd223 on January 17, 2022, 04:48:05 PM

Title: How to "Search and Replace" special characters?
Post by: asdasdasd223 on January 17, 2022, 04:48:05 PM
I'm trying to remove "; Example" from "Test; Example" in the Genre tag. But when I use "Search and Replace" it says "No Matches Found". When I search for only "Example" then it finds everything. Why does ; screw it up?

I have Advanced Search and Replace but every preset is way too specific like "Remove EVERYTHING after and including <Custom Text 1>" which would mess up tags that have stuff after what I want to remove:
"Test; Example; I want to keep this part"

What else can I do?
Title: Re: How to "Search and Replace" special characters?
Post by: Mayibongwe on January 17, 2022, 04:55:57 PM
$Trim($Replace($Replace(<Genres>,; Example,),Example;,))

That's all that was needed I guess.
Title: Re: How to "Search and Replace" special characters?
Post by: The Incredible Boom Boom on January 17, 2022, 05:15:17 PM
I'm trying to remove "; Example" from "Test; Example" in the Genre tag. But when I use "Search and Replace" it says "No Matches Found". When I search for only "Example" then it finds everything. Why does ; screw it up?

The semicolon is the visual representation of the NULL character value in multi-value tags.
You don't have to include it in your searches, just remove "Example."
Title: Re: How to "Search and Replace" special characters?
Post by: hiccup on January 17, 2022, 05:44:40 PM
The semicolon is the visual representation of the NULL character value in multi-value tags.
You don't have to include it in your searches, just remove "Example."
If the question is strictly about removing certain characters in tags, that would work.
But I am guessing the OP wants to remove a complete value in a multi-value tag.
As it happens I struggled with something like that myself recently, and I failed to find a good solution.

Suppose a track has values for the tag 'Keywords' such as: aaa, bbb and ccc, and you want to remove the bbb value.
By simply using text replace, you would get something like this:

(https://i.imgur.com/Xmyv5uj.png)

So this would probably need some regex magic.
I've tried a few solutions, using anchors for start/end etc., but none of them worked perfectly for all these examples.

So I am interested too if someone has the perfect solution.
Title: Re: How to "Search and Replace" special characters?
Post by: hiccup on January 17, 2022, 06:36:01 PM
Hm, this seems to work:

(https://i.imgur.com/CJr2vca.png)

I would swear I tried something like this before and failed.
So anyone interested, try it out on several situations before you decide to use it on your valuable library.
Title: Re: How to "Search and Replace" special characters?
Post by: Mayibongwe on January 17, 2022, 06:51:13 PM
@hiccup, don't virtual tags work for the scenarios you described above? (using the replace function to replace a value in <keywords>)
Title: Re: How to "Search and Replace" special characters?
Post by: The Incredible Boom Boom on January 17, 2022, 06:56:57 PM
Suppose a track has values for the tag 'Keywords' such as: aaa, bbb and ccc, and you want to remove the bbb value.
By simply using text replace, you would get something like this:

(https://i.imgur.com/Xmyv5uj.png)

So this would probably need some regex magic.

Oh, ok, that makes. In that case...

search for:
Code
Example.+?(\w)
replace with:
Code
$1
And check the regular expression box


@hiccup, don't virtual tags work for the scenarios you described above? (using the replace function to replace a value in <keywords>)

<Genre> only returns the first value. <Genres> returns all of them.
Title: Re: How to "Search and Replace" special characters?
Post by: Mayibongwe on January 17, 2022, 07:03:08 PM
<Genre> only returns the first value. <Genres> returns all of them.
Never had to use <Genres> before, so I didn't know about it. Thanks for letting me know that.
Title: Re: How to "Search and Replace" special characters?
Post by: hiccup on January 17, 2022, 07:03:26 PM
@hiccup, don't virtual tags work for the scenarios you described above? (using the replace function to replace a value in <keywords>)
Yes, but that will only work for displaying purposes, using that virtual tag.
Using an AT&RT preset like this will remove the tag from the file/library, so it won't display anywhere any more.
Title: Re: How to "Search and Replace" special characters?
Post by: Mayibongwe on January 17, 2022, 07:07:31 PM
Yes, but that will only work for displaying purposes, using that virtual tag.
Using an AT&RT preset like this will remove the tag from the file/library, so it won't display anywhere any more.
Oh okay I see. Thanks. I've always preferred using virtual tags (I find it easier than using the regEx you mentioned) and then using the AT&RT to copy the virtual tag into whatever tag I was dealing with.
Title: Re: How to "Search and Replace" special characters?
Post by: hiccup on January 17, 2022, 07:15:17 PM
(I find it easier than using the regEx you mentioned) and then using the AT&RT to copy the virtual tag into whatever tag I was dealing with.
To each his own, but if you use such a feature frequently it's much easier to have an ASR preset available for it.
You can then e.g. simply have a shortcut to open it.
 
I already have one for adding a specific tag to existing ones:
https://getmusicbee.com/forum/index.php?topic=35032.0

I'll add a download for this 'remove a tag' ASR preset to the above post at a later moment.
(after I am confident it indeed works well and is reliable)
Title: Re: How to "Search and Replace" special characters?
Post by: hiccup on January 18, 2022, 04:29:30 PM
I'll add a download for this 'remove a tag' ASR preset to the above post at a later moment.
(after I am confident it indeed works well and is reliable)
After some more testing and some refinements I am now confident it works well.

The presets can be found and downloaded here:
https://getmusicbee.com/forum/index.php?topic=35032.msg191625#msg191625