Expression to delete defined strings from tag

Hello,

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.

Try
' [.*]'
(fewer apostrophes, added )

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:
/

Still does not work

Patterns to remove leading zeros from the track field are:

Multiple

$regexp(%track%,^0+,$1)

single

$regexp(%track%,^0,$1)

Though removing leading zeros will 'break' sorting in Windows Explorer and media player applications, so fracks will become ordered as

1
10
11
.
.
19
2
20
21
...

and so on.

to remove the leading zero after the '/' will need an action group creating with running this replace first

$replace(%track%,/0,/)

then the regexp in the post above.

Never tried in MP3Tag but I don't think nested regular expressions are going to be possible.

Sorry, i was puzzled and made it far too complicated.
[.*]
will do it

?????

That would just leave \ in the track field

A regex match pattern of .* means "match any character (except newline [ASCII 13] ) 1 or more times"

You are probably right - I was refering to the second problem with the square brackets part and not the track number problem.

Doesn't a regexp to empty a field though

You can
Ctrl+A (select all)
select in the tag panel then Ctrl+S to save

Or for scripting/Convert (Alt+5)

Set the field and an action of $replace(%field%,)

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.

Apologies I had misread the post.

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?

Regular expressions are 'greedy' by nature, meaning they will match as much as possible,

If you add a ? after the repeat, it makes the match 'non-greedy' so it matches the shortest possible string

and instead of \d\d\d\d use a repeating set, so a 'non-greedy four digit pattern is;

\d{4}?

Thank you, it works perfectly

\d{4}? The question mark there makes no sense to me, what's the difference from \d{4}

The ? makes the match "non-greedy"

\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

http://www.regular-expressions.info/repeat.html

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

In that case.
The MP3Tag help needs rewriting

The document at regular-expression.info linked in earlier post.

The technical spec for a Perl regex

AND The POSIX specifications for the 'Boost' regex library.
http://www.boost.org/doc/libs/1_55_0/libs/...ic_syntax.emacs

..... .....

But I'll take your word for the appended '?' not setting a non-greedy repeat when following a group or an atomic repeat.