# Help building correct Regular Exprssions - https://regex101.com/

**URL:** https://community.mp3tag.de/t/help-building-correct-regular-exprssions-https-regex101-com/62470
**Category:** Support
**Created:** [October 19, 2023, 9:42pm UTC](https://community.mp3tag.de/t/help-building-correct-regular-exprssions-https-regex101-com/62470 "2023-10-19T21:42:01Z")
**Posts on this page:** 1
**Showing post:** 4

<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 20, 2023, 1:53pm UTC](https://community.mp3tag.de/t/help-building-correct-regular-exprssions-https-regex101-com/62470/4 "2023-10-20T13:53:42Z")

</div>

> [@gstalnaker](#):
>
> Format: Discnumber: `$regexp(%_directory%,^(\w+\s\w+\s\w+\s)(\d{3})(.*),$2)`

Please be aware that this regular expression only works if your fourth value `(\d{3})` always has exactly 3 numbers. As you can see in [this regex101-examples, some possible variants would not match.](https://regex101.com/r/bmEOBL/1)

IMHO if you really only need the DISCNUMBER from the directory name It would be easier to use the Convert Filename -\> Tag and this formatstring:  
`%dummy% v03CD%DISCNUMBER% %dummy%\%dummy%`

 ![image](https://community.mp3tag.de/uploads/default/original/2X/d/d9ccf6f3f417cf1d6ddb7f3aaf3b5b8bcff80735.png)  
The Convert function has also the advantage that you can immediately see the result as  
**DISCNUMBER** 15  
For more details about the Convert Filename -\> Tag please see the [F.A.Q:](https://community.mp3tag.de/t/converters-to-rename-files-or-to-import-tags/8016/3#how-to-import-parts-of-the-folder-structure-into-the-tag-2).

This does not at all mean that your contribution is not valuable. It is just important to know that regular expressions only works for exactly the situation they were built for.

---

_[View the full topic](https://community.mp3tag.de/t/help-building-correct-regular-exprssions-https-regex101-com/62470)._
