How to retain text within quotes and discard the rest?

Hello,

I cannot appreciate enough how well written mp3tag is, so thank you to the devs!

I would like to edit the album title so that only the text within two double quotes is retained while discarding anything that is before and after the the double quotes. Example below:

Current tag for Album field: Nexus sky (From "Distant Star Always") asteroid
Expected result for Album field: Distant Star Always

I am guessing I need to use Replace with regular expression? Any advise would be great. Thanks!

Try an action of the type "Replace with regular expression" for ALBUM
Search pattern: .*"(.*)".*
Replace with: $1

Thanks for the reply! I tried your suggestion but got this error:
"The repeat operator "*" cannot start a regular expression.

I did figure out the solution though :robot:

You create a new action "Replace with regular expression" and in regular expression, use
.*"([^"]+)".*
and replace with
$1

Are you sure @vicosphi ?

The mentioned error


only occurs, if you missed the leading dot in the regular expression as
incorrect: *"(.*)".*
correct : .*"(.*)".*

In my own test @ohrenkino's regular expression works fine and


modifies the ALBUM content
Nexus sky (From "Distant Star Always") asteroid
to the new ALBUM content
Distant Star Always

Thanks again! That worked as well. I must have missed the period earlier. Appreciate the help!

To compare the two solutions:
.*"(.*)".* means

.*"([^"]+)".* means


IMHO this expression is more difficult to read and understand because of the grouping after the first " character.
Instead of grouping any character it is using none of " until reaching the last " character.

The description none of " can also be translated as
Match a single character not ^ present in the list. (The list []contains ")
The + matches the previous token between one and unlimited times,

And BTW:
Please be careful - with both expressions - if your current content in ALBUM contains 3 or more " characters.

I've dug into this a bit.
If you always want the content of the first double quote pair, you can achieve that by making the first two asterisks non-greedy like this:

.*?"(.*?)".*

Is the desired outcome the content of the last double quote pair, only make the asterisk in the capturing group non-greedy:

.*"(.*?)".*

And when you want to match a range in many double quotes, you can adapt the regex like this:

(?:.*?"){1}(.*?)".*

this will match the first pair

(?:.*?"){3}(.*?)".*

would match the second pair

(?:.*?"){5}(.*?)".*

would match the third pair and so on.