Issue with regular expression

Hello,

I'd like to transform

"Song title (Live) (feat. another singer & artist) "

into

"Song title (Live)"

Coming from Perl, I would use

$regexp(%title%,\s+\([^()]+\)\s*$,)

but unfortunately it does not work :unamused:
Any idea?

Best regards,
Andreas

I would have a look at the help instead
http://help.mp3tag.de/options_format.html#regexp

This should work

$regexp('Song title (Live) (feat. another singer & artist)','^(.*\)) \(.*$',$1)

In this case, scripting help seems more relevant:

Characters with special functionality

  • [...] The contents of brackets are displayed only if at least one of the placeholders used inside the brackets has been found.
  • ' Outputs raw text without parsing. This will output the contained string and ignore all reserved characters. If you want to output this character, please use ''.
  • []$% You have to put a single quote around these reserved characters if you want to use them unparsed.
  • ,() These characters must only be escaped when they are inside a scripting function.

$regexp(x,expr,repl) replaces the pattern specified by the regular expression expr in the string x by repl. The fourth optional parameter enables ignore case (1) or disables the ignore case setting (0). Please note that you have to escape comma and other special characters in expr.

I would recommend to try a greedyness modifier instead of the negated character class:

$regexp(%title%,\s+\(.+?\)\s*$,)

1 Like

Hello,

Thank you for your help so far.
Please let me specify my issue a bit more:

I have an example with three different titles strings:
TITLE (Text1) (to be deleted)
TITLE (Text1) (Text2) (to be deleted)
TITLE (Text1) (Text2) (Text3) (to be deleted)
My aim is to get rid of the last pair of parens only.
Maybe it is too naive to take a regular expression that works fine in Perl, Java, ... and try it out here.
But when the help says: [^abc] alle Zeichen, ausser "a", "b" und "c"
then I do believe it.
And since the last parens may contain any kind of text, it is easier to say: anything but parens!
The non-greedy expression of Crissov simply deleted all parens.
ohrenkino' expression did what I intended to do :slight_smile: Thank you very much!!

Now my question: why did the expression with the negate syntax not work?
Acc. to the help text it should work (as I said, tested in Perl).
Is there a bug?

But so far I am happy with an expression deleting the last pair of parens :slight_smile:

Hello again,

I have tried it another time:
$regexp(%title%,'\s*\([^()]+\)\s*$',)

Believe it or not: It now works!
There is a tiny difference to my first attempt:
$regexp(%title%,\s+\([^()]+\)\s*$,)

I left out the '

Now my world is fine again :smiley: :slightly_smiling_face: :upside_down_face: :slightly_smiling_face: :smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.