# Reworking of a half-working code

**URL:** <https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366>\
**Category:** Support\
**Created:** [October 24, 2016, 4:53pm UTC](https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366 "2016-10-24T16:53:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [October 24, 2016, 4:53pm UTC](https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366/1 "2016-10-24T16:53:40Z")

</div>

So I have this two codes

```
Format value: "TITLE": $regexp(%TITLE%,'(\[.*?\])','\U$1\E')and
Format value "TEMPORARY": $regexp(%TITLE%,'^(.*?)(\[.*?\])(.*?)$','$2')
Format value "TEMPORARY": $regexp(%TEMPORARY%,'\s+',)
Format value "TEMPORARY": $regexp(%TITLE%,'^(.*?)(\[.*?\])(.*?)$','$1'%TEMPORARY%'$3')
Format value "TEMPORARY": $char(0)

```

The first action changes any small letters into capital ones that are in placed in brackets; even when there are many instances of [] throughout the TITLE tag value

And the second action removes any spaces between any kind of characters in brackets; but only in the first instance of them

[Both tasks are independent of each other]

So how is the second code need to be reworked, based on the first one, so that it also would apply itself to infinite number of brackets? For example it should change this

```
Song Aaa [x] (Instrumental) + Song Bbb {2000 Mix} [Y2] vs. Song Ccc [xYZ 9- 110]not merely to this
Song Aaa [x] (Instrumental) + Song Bbb {2000 Mix} [Y2] vs. Song Ccc [xYZ 9- 110]but precisely into this
Song Aaa [x] (Instrumental) + Song Bbb {2000 Mix} [Y2] vs. Song Ccc [xYZ9-110]?
```

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [October 24, 2016, 5:18pm UTC](https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366/2 "2016-10-24T17:18:28Z")

</div>

Use a positive lookahead 🙂 This action will replace all those you have currently.

```
$regexp(%title%,'\s+(?=[^[\]]*\])',)
```

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [October 24, 2016, 5:22pm UTC](https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366/3 "2016-10-24T17:22:44Z")

</div>

DAMN! I've got to 666 posts. That's better!!

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [October 25, 2016, 10:59am UTC](https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366/4 "2016-10-25T10:59:51Z")

</div>

> [@stevehero](#):
>
> Use a positive lookahead 🙂 This action will replace all those you have currently.
> 
> ```
> $regexp(%title%,'\s+(?=[^[\]]*\])',)
> 
> ```

Are you a magician or something?

Thank you very much

> [@stevehero](#):
>
> DAMN! I've got to 666 posts. That's better!!

No, it's 667 now

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [October 25, 2016, 4:16pm UTC](https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366/5 "2016-10-25T16:16:16Z")

</div>

> [@zerow](#):
>
> Are you a magician or something?
> 
> Thank you very much
> 
> No, it's 667 now

![:sorcerer:](https://community.mp3tag.de/uploads/default/original/1X/73535d0e07591636841ac7aadccc8f7ff56e7807.gif ":sorcerer:")

If you have 30$ lying around try Regexbuddy. [https://www.regexbuddy.com/buynow.html](https://www.regexbuddy.com/buynow.html)

Amazing tool to learn the ins and outs of regular expression and to build them also.

Yeah it was that when I posted that. 😉

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [February 9, 2026, 12:26pm UTC](https://community.mp3tag.de/t/reworking-of-a-half-working-code/18366/6 "2026-02-09T12:26:30Z")

</div>


