Author Topic: How to "Search and Replace" special characters?  (Read 1162 times)

asdasdasd223

  • Jr. Member
  • **
  • Posts: 22
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?

Mayibongwe

  • Hero Member
  • *****
  • Posts: 525
$Trim($Replace($Replace(<Genres>,; Example,),Example;,))

That's all that was needed I guess.
Last Edit: January 17, 2022, 07:00:30 PM by Mayibongwe
Bit busy of late.
I cannot frequent the forum on a regular basis like I used to - but I will be responding whenever I get the time.

The Incredible Boom Boom

  • Hero Member
  • *****
  • Posts: 899
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."

hiccup

  • Hero Member
  • *****
  • Posts: 6562
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:



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.

hiccup

  • Hero Member
  • *****
  • Posts: 6562
Hm, this seems to work:



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.

Mayibongwe

  • Hero Member
  • *****
  • Posts: 525
@hiccup, don't virtual tags work for the scenarios you described above? (using the replace function to replace a value in <keywords>)
Bit busy of late.
I cannot frequent the forum on a regular basis like I used to - but I will be responding whenever I get the time.

The Incredible Boom Boom

  • Hero Member
  • *****
  • Posts: 899
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:



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.

Mayibongwe

  • Hero Member
  • *****
  • Posts: 525
<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.
Bit busy of late.
I cannot frequent the forum on a regular basis like I used to - but I will be responding whenever I get the time.

hiccup

  • Hero Member
  • *****
  • Posts: 6562
@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.

Mayibongwe

  • Hero Member
  • *****
  • Posts: 525
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.
Bit busy of late.
I cannot frequent the forum on a regular basis like I used to - but I will be responding whenever I get the time.

hiccup

  • Hero Member
  • *****
  • Posts: 6562
(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)

hiccup

  • Hero Member
  • *****
  • Posts: 6562
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