i start this with beeing plain honest, i tried now several hours with some ChatGPT help to get this Regexp to work, but it doesn´t, so may some of you explain to a noob why this is not working in any way.
Case:
I have a huge amount of files which are particialy grouped, where the Tags in album are the same for every group.
Episode 1: Word Word
Episode 1: Word Word (←—basicaly antoher part of the whole audio group Episode 1)
Episode 2: AnotherWord Word
Episode 2: AnotherWord Word (←—basicaly antoher part of the whole audio group Episode 2)
and so on.
So now i try to extract ONLY the number to copy it to the tag “series-part”.
Chatgpt gave me this expression which i added to an action and there into tag-forma, $regexp(%album%,Episode ([0-9]+),$1) but i always end up with “Redexp Error: Regular Expression” .
as in regular expression each character matters to define the pattern, a real example would be helpful.
To get a number try \d, e.g
Convert>Tag-Tag for "series part"
Format string: $regexp(%album%,.*(\d+).*,$1)
It fails, because the square brackets [ and ] are special characters in a regular expression. They have to be "escaped". In your case, you can enclose it in Mp3tag with ' to look like this: $regexp(%album%,Episode ('[0-9]'+),$1) (I have not checked if this expression works as expected!
It's just the explanation for the error message:
)
Update:
One way to use your regular expression to only get the number 2 in your example would be: $regexp(%album%,Episode ('[0-9]+'):.+,$1)
Thanks guys for the fast reply, really appriciate it.
In my particular case it works as intended for the first 9, but only as long as there is no second digit and no twodigit number - it fails in two cases:
Episode 10: Word Word Word —–> Ends in a 0
Episode 5: Word Word Word (Part1) —→ Ends in a 1
Luckily the second case doesn´t apply this time, as there are only digits infront of the dash, but the twodigit problem stays.
Just for protocoll this ends in (example) “1: Word Word Word” - so it copies the text also.
This works flawlessly with my case, it also even works (especialy tested it) with the second digit at the end (if there would be something like “Part 1” or such a thing)
A BIG THANKS!
I´d like to ask such questions in english, as most of the germans speak english, but it would be a different story the other way around - so this way everyone can profit from this thread maybe…
That is why I asked to get a real example. Your first examples only had single digits and no digits somewhere in the string.
Try this: $regexp(%album%,.*?(\d+).*,$1)