I am trying to delete certain strings from my tag using expressions. First, I have tracks that are like "03/10" or "01/07" and I just want it to be "3/10" and "1/7". However, if I search specifically for "0" to replace as nothing, things like "03/10" will be "3/1" which would not work. Is there a better way say, to only delete leading zeroes?
Secondly, I have Album titles as xxx [xxx] but I want to delete everything in and including the square brackets.
At least 2 solutions:
1: use the numbering wizard and renumber your files.
2: Create an action of the type "Replace with regular expression" for TRACK
Enter as search string: ^0
Leave format string empty.
Second case, same type of action. Only this time other field and enter as search string:
' ['.*']'
again: leave the search string empty
Thank you, but is it possible for the second solution to modify the total tracks too because only the current track works eg. 1/07. Also, the search string input for the square brackets one don't work.
For the track number stuff:
add an action of the type simple "Replace" to the already created action (Select the action group, klick Edit, klick New)
enter as search string:
/0
enter as replace string:
/
Are you discussing this theoretically or have you tried it?
The op's request was to delete a text in square brackets, but leave the rest.
And this is exactly what the [.*] will do.
It will take that part of the string that has a square bracket at the beginning, something in between and a square bracket at the end and replace it with nothing. The rest of the field will remain unaltered.
Thank you all for the help. One final request:
I have fields with repeated strings eg. 'DATE' = '2014-01-17 2014-01-17 2014-01-17' and looking through my tagging script it seems this is creating the duplicate strings:
Is there a way I can fix this or an action group to fix it afterwards?
\d{4} would match any and all four digit sequences in the same string, adding the ? AFTER the repeat means it will only match the shortest possible sequence.
so $regexp(' 1234 1234 1234',\d{4} $1) will return the entire string without the spaces ie; '123412341234' (greedy), whereas $regexp(' 1234 1234 1234',\d{4}?, $1) will only return the first sequence of '1234' which is the shortest possible match from that string, so is a 'non-greedy' or a 'lazy' match.
More on "laziness' vs 'greediness' in Regular Expressions
I thought about it and my take is that your explanation is not correct.
The ? on \d{4}? has no effect. {4} if a fixed repetition.
It only works with i.e. \d{4,6}? or \d{4,}?
You're mixing up greediness with global matching which means how often a complete pattern is matched in a string (either just one time or as often as possible). This is activated in Mp3tag (match as often as possible) and cannot be changed afaik.
Example:
$regexp(aaa,a{1},) => empty
$regexp(aaa,a{1}?,) => empty
If global matching was off (match only one time) the result would be aa