# What's missing for this regex replace expression? DISCNUMBER "1 / 2" or "2 / 2" etc

**URL:** <https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299>\
**Category:** Support\
**Created:** [October 5, 2023, 4:20pm UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299 "2023-10-05T16:20:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 5, 2023, 4:20pm UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299/1 "2023-10-05T16:20:53Z")

</div>

Hello there, I have a regular expression to detect the discnumber and convert to single digit. It's always been fine but now it's not changing my example.

 ![image](https://community.mp3tag.de/uploads/default/original/2X/7/7483642248d6b6b3ab7017d4d7c2ed3c4c7da21e.png)

 ![image](https://community.mp3tag.de/uploads/default/original/2X/f/f9fbe0b0894501db9c13da76144f439fbcbeb8e5.png)

I just want it to show as 1, 2 or any relevant number that the disc is.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [October 5, 2023, 4:23pm UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299/2 "2023-10-05T16:23:45Z")

</div>

If your DISCNUMBER looks like  
`1 / 2`  
you have to adjust your regular expression to include the space before and after the / slash

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 5, 2023, 4:32pm UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299/3 "2023-10-05T16:32:40Z")

</div>

Is there an action I can use that will deal with both instances in the same way? Perhaps conditional?

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [October 5, 2023, 4:59pm UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299/4 "2023-10-05T16:59:31Z")

</div>

You can try it with  
`(\d+).*/.*\d+`

Explanation:  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/a/a1ebfbc48716547b0f583d42e19e7f3ff523d20a.png)

"Any character" can also be "no character".  
Therefore it matches the number 1 from  
`1/2`  
as well as in  
`1 / 2`

Please be aware that you can not undo this step.  
The information about how many discs your current album has (2 in the above example) is gone after appying this regular expression. It only remains the discnumber itself.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [October 5, 2023, 5:06pm UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299/5 "2023-10-05T17:06:17Z")

</div>

Thank you, that works perfectly and the explanation was really good too. I'm pleased to be left with only one digit in the DISCNUMBER.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 6, 2023, 5:06am UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299/6 "2023-10-06T05:06:56Z")

</div>

The same could have been achieved with an action of the type "Format value" for DISCNUMBER  
Format string: `$num(%discnumber%,1)`

---

<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:** [November 5, 2023, 5:07am UTC](https://community.mp3tag.de/t/whats-missing-for-this-regex-replace-expression-discnumber-1-2-or-2-2-etc/62299/7 "2023-11-05T05:07:44Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
