An Elegant Solution please - regex

Hi All,

I have a number of tags where %ALBUM% is 'Name Of Album' with the inverted commas around it (this is due to a 'tag from filename' error, which was completely my fault.)

I know it's easy enough to re-do the extract tag from filename and just use:

%ARTIST% - %TITLE% - '%ALBUM%' - %TRACK%

which will ignore the inverted commas when creating the %ALBUM% tag, but I wondered if there was a more elegant way using regex?

What I'd love to do is set up an ACTION where I can remove inverted commas from either side of a string, but ONLY if they exist on both sides (ie a conditional expression). So:

'AROUND THE CORNER' becomes AROUND THE CORNER, but
'ROUND THE CORNER remains unchanged, as it's a deliberate inverted comma.
And, presumably, ''ROUND THE CORNER' will change to 'ROUND THE CORNER, stripping the first and last characters but leaving the second in place.

And, for good measure, would it be possible to adapt this to remove ANY CHARACTER from either side of a string, perhaps by allowing a user variable (I'm not sure if this level of interaction is possible in regex!). So we would have the option to edit tags such as:

(I DON'T LIKE BRACKETS)
OR UNDERSCORES
[OR SQUARE BRACKETS]
{OR SQUIGGLY ONES}
"OR QUOTE MARKS"

Quite an ask, I grant you, but there must be someone out there who could do this with his or her eyes shut.

Possibly this is a challenge to the poster 'pone', who seems to like elegant solutions!

Thanks

Miles.

REASON FOR EDIT: Changed 'with his eyes shut' to 'with his or her eyes shut'. Ooops!

This is bad syntax ... when creating a string ... %ARTIST% - %TITLE% - '%ALBUM%' - %TRACK% It is better to use ... %ARTIST% - %TITLE% - ''%ALBUM%'' - %TRACK% ... or ... %ARTIST%' - '%TITLE%' - '%ALBUM%' - '%TRACK% ... or ... %ARTIST% - %TITLE% - %ALBUM% - %TRACK%

Choose the right syntax for the right case.

When guessing values from the filename, your string mask seems to be ok and can automatically remove the two apostroph characters, which surrounds the album part.

For this case use one of the functions $trim, $trimLeft, $trimRight, e. g.

$trim(%ALBUM%,'')

... or ...

$trim(%ALBUM%,'[]{}()"_')

... or ...

$trim(%ALBUM%,'[]{}()"_''')

This scripting expression removes a pair of apostroph characters from both sides of the given string, if there any ...

$if($eql('''',$left(%ALBUM%,1)$right(%ALBUM%,1)),$cutLeft($cutRight(%ALBUM%,1),1),%ALBUM%)

...or ...

$if($eql($char(39)$char(39),$left(%ALBUM%,1)$right(%ALBUM%,1)),$cutLeft($cutRight(%ALBUM%,1),1),%ALBUM%)

DD.20140518.1717.CEST, DD.20150516.0942.CEST