How to remove apostrophes from search query w/ $regexp?

Discogs throws up 401 errors with queries containing apostrophes. So, I try to strip apostrophes (and other offending characters) from my queries. Everything else but apostrophes are stripped. Trying to include an escaped apostrophe (,) in the bolded array below doesn't work and including an apostrophe doesn't work due to the bordering bracket(?) apostrophes. Any other ideas?

[SearchBy]=$if($eql(%albumartist%,'Various Artists'),'Various'&release_title=$regexp($regexp(%album%,'\s+[.+]$',,1),'[-.,+!(){}[]^"~*?:\\]',),$regexp($regexp(%albumartist%,'\s+[.+]$',,1),'[-.+!(){}[]^"~?:\\]',)&release_title=$regexp($regexp(%album%,'\s+[.+]$',,1),'[-_.+!(){}[]^"~?,:\\]',))

http://help.mp3tag.de/main_scripting.html

Try escaping ' with ''. (that's 2 single apostrophes)

I tried it already (I should've included that in my OP), but while I avoid [SYNTAX ERROR] it doesn't strip out the apostrophes.

&release_title=$regexp($regexp(%album%,'\s+\[.+\]$',,1),'[-_''.+!(){}\[\]^"~*?,:\\\\]',))

Likewise, the same output occurs in the following:

&release_title=$regexp($regexp($regexp(%album%,'\s+\[.+\]$',,1),'[-_.+!(){}\[\]^"~*?,:\\\\]',),'',)

input: 60's Beat Girls Collection, Vol. 1: Japanese Pop Cuties in Swingin' 60's
output: 60's Beat Girls Collection Vol 1 Japanese Pop Cuties in Swingin' 60's

I tested your code in the tag panel and it seems to work as you require. See attached.


I intended to use the code in a websource discogs (see [SearchBY] in OP), hence my attempt to workaround Discog's contempt (401 errors) for nearly all punctuation marks in the search query. I never tried it in an action script.

For example (album: Leaders Of The Pack: The Very Best Of The 60's Girls), running my discogs websource, the current code yields the following query:

https://api.discogs.com/database/search?typ...e_title=Leaders Of The Pack The Very Best Of The 60's Girls

As you can see, all of the punctuation marks are stripped except the apostrophe. When running this query, discogs throws up a 401 message.

Pone's discogs script strips out ('s), but it leaves trailing apostrophes around (i.e. Swingin')

The following query works (w/o the apostrophe), but my code is unable to strip it out.

https://api.discogs.com/database/search?typ...e_title=Leaders Of The Pack The Very Best Of The 60s Girls

EDIT: Even a simple removal of any non-alphanumeric characters (/[^a-zA-Z0-9]/g) still leaves apostrophes behind in the ParserScriptIndex. Something is very wrong here.

https://regex101.com/r/pI8xA4/3

You may try this formatstring ...

$regexp(%ALBUM%,'(\s+\[.+\]$)|\x27|'$regexp('-_.+!(){}[]^$~*?,:\','.','|\\\\$0'),,1)

... or ...

$regexp(%ALBUM%,'(\s+\[.+\]$)|\x27|[^\w\s]',,1)

DD.20160404.2306.CEST

When I use the links to your examples I get this:
{"message": "You must authenticate to access this resource."}

I guess that is because I'm not authenticated on your account.

But using the default SRC script (discogs.src), I just searched for this: deliverin' the good's
There was 11 results.
So it seems it's possible to search with apostrophes in the string.

Then I modified the script with your regex replacements and tried again and got the same 11 search results.
Maybe it's something other than apostrophes that cause the problem.

So then I tried your original input example.
That produced the 401 error.
But when I tried the same string without the dot after "Vol" I got the "Sorry, no entries..." message.
I guess that means something.

Have fun sorting it out!

Maybe a real expert will help. I'll keep experimenting, but I don't know much about source scripts.

Okay, I am a dumbass. I now realize that bypassed my %albumartist% $if statement when trying out my code. All of this time I triggered that $if statement when testing the code out on compilation albums (albumartist=Various Artists). The escape character for apostrophes worked as expected, but I have to admit that DetlevD's regex looks a lot cleaner.

Anyways, thanks guys for the help. I'm no expert myself. I just read some docs, looked at some old sources and created a few unavailable ones for personal use.

Ryerman you are correct in saying that apostrophes are accepted with the regular discogs.src. I opened up my browser and tried the search string from Pone's script and it worked:
https://api.discogs.com/database/search?type=release&per_page=100&artist=Various&release_title=Leaders Of The Pack: The Very Best Of The 60's Girls&token=(my token 'without the parenthesis')

You're never a dumbass when you make an honest mistake, but then find and correct it.
At least you had the decency to come back and explain (not that I understand :wink: ).
Not everybody does that.

DetlevD is one of the resident Regex experts around here. I'm not.