# $regexp(x,e,r,c)

**URL:** https://community.mp3tag.de/t/regexp-x-e-r-c/69158
**Category:** Support
**Created:** [July 20, 2025, 2:40pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158 "2025-07-20T14:40:02Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![confucius](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@confucius](https://community.mp3tag.de/u/confucius)
#### Post date: [July 20, 2025, 2:40pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/1 "2025-07-20T14:40:02Z")

</div>

"in the string x by r".  
Sorry for being so dim, but this has baffled me, "by r" what does this mean? What should I be replacing r with?

Some examples [here](https://docs.mp3tag.de/scripting/) would go a long way to helping your users out.

replaces the pattern specified by the [regular expression](https://docs.mp3tag.de/regex) e in the string x by r. The optional fourth parameter c enables ignore case (`1` ) or disables the ignore case setting (`0` ). Please note that you have to escape comma and other special characters in e.

---

<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: [July 20, 2025, 2:49pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/2 "2025-07-20T14:49:38Z")

</div>

> [@confucius](#):
>
> "by r" what does this mean?

The pattern that has been described in the parameter "x" is replaced with/by that what is stated in the parameter "r".  
In a simple replace "water" would be replaced by"wine".

---

<div class="post-metadata">

### Author: ![confucius](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@confucius](https://community.mp3tag.de/u/confucius)
#### Post date: [July 20, 2025, 3:08pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/3 "2025-07-20T15:08:07Z")

</div>

Thank you ohrenkino.

Yes, "with" would be the right word most people would use!  
Anyway...  
I have $regexp(%\_directory%,\W\s\D,r,c). This picks up JAS 02 from the directory "JAS 02 - ...." and placing it in the comment field and I would like it to be JAS02.  
I'm still working on the rest of this action. But this one bit puzzled me!

---

<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: [July 20, 2025, 3:11pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/4 "2025-07-20T15:11:35Z")

</div>

Could you give the real source string with all the bits and tell us what the result should be?  
Right now the "r,c)" part does not look right.

---

<div class="post-metadata">

### Author: ![confucius](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@confucius](https://community.mp3tag.de/u/confucius)
#### Post date: [July 20, 2025, 3:52pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/5 "2025-07-20T15:52:29Z")

</div>

It incomplete, but...  
I'm doing two things here, formatting the comment and then moving the file.

It may be best to say what I'm aiming for.  
My directory's names are:  
JAS 04 - artist - album  
JAS 204 - artist - album  
JAS 205 - artist - album

I want to copy JAS 04 to the comment field adding "Jasmine Records No. ", but without the space "Jasmine Records No. JAS04".

Format value "COMMENT" Jasmine Records No. $left(%\_directory%,6)  
Then a replace "JAS " with "JAS".

For the move the below works, but I have to moving the rest of the contents of the folder manually.  
W:\_JASMINE$left(%\_directory%,3)~$right(%comment%,3) = %artist% - %album% $if($neql(%\_extension%,mp3),{FLAC},{@ 320})%track% = %artist% - %title%

I've read that this may be not a one ling job, so the directory structure I'm after is  
W:\_JASMINE\JAS~04 = Duke Ellington - Duke meets coleman {FLAC}\the files

My workings so far....  
$left(%\_directory%,3)~$right(%comment%,3) = %artist% - %album%  
$if($neql(%\_extension%,mp3),{FLAC},{@ 320})

$left(%\_directory%,3)~$right(%comment%,3) = %artist% - %album% $if($neql(%\_extension%,mp3),{FLAC},{@ 320})%track% = %artist% - %title%

EDIT  
Done this a TAG to Filename.

---

<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: [July 20, 2025, 3:55pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/6 "2025-07-20T15:55:57Z")

</div>

> [@confucius](#):
>
> Format value "COMMENT" Jasmine Records No. $left(%\_directory%,6)

You could modify that  
Format string: `Jasmine Records No. $replace($left(%_directory%,6), ,)`

---

<div class="post-metadata">

### Author: ![confucius](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@confucius](https://community.mp3tag.de/u/confucius)
#### Post date: [July 20, 2025, 3:58pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/7 "2025-07-20T15:58:00Z")

</div>

Doh! of course I can, silly me. Thank you.

---

<div class="post-metadata">

### Author: ![confucius](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@confucius](https://community.mp3tag.de/u/confucius)
#### Post date: [July 20, 2025, 4:04pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/8 "2025-07-20T16:04:39Z")

</div>

I've been reading post HERE [Move folder.jpg along with MP3 files to new directory](https://community.mp3tag.de/t/move-folder-jpg-along-with-mp3-files-to-new-directory/14375)

---

<div class="post-metadata">

### Author: ![confucius](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@confucius](https://community.mp3tag.de/u/confucius)
#### Post date: [July 20, 2025, 4:19pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/9 "2025-07-20T16:19:49Z")

</div>

I think I was trying to do to much in one line.  
So now i do the copy to comment,  
then the file rename,  
then the move.

Jasmine Records No. $replace($left(%\_directory%,6), ,)

%track% = %artist% - %title%

W:\_JASMINE$left(%\_directory%,3)~$right(%comment%,3) = %artist% - %album% $if($neql(%\_extension%,mp3),{FLAC},{@ %\_bitrate%})\

And this works.

So was my understanding of the regex thing incorrect?

EDIT

I was trying the regex so that it would cover these directories (added the dash)  
JAS 03 - ...  
JASM 1034 - ...  
JASMCD 3077 - ....

Anyway thank ohrenkino.

---

<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: [July 20, 2025, 4:56pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/10 "2025-07-20T16:56:01Z")

</div>

> [@confucius](#):
>
> JAS 03 - ...  
> JASM 1034 - ...  
> JASMCD 3077

To extract the leading string without space:  
`$regexp(JASMCD 3077 - artist - album,(.*?) (\d+) - .*,$1$2)`  
(I used this as an example string - the real thing would probably be:)  
`$regexp(%_directory%,(.*?) (\d+) - .*,$1$2)`

---

<div class="post-metadata">

### Author: ![confucius](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@confucius](https://community.mp3tag.de/u/confucius)
#### Post date: [July 20, 2025, 5:11pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/11 "2025-07-20T17:11:45Z")

</div>

Oh I see where I was going wrong now.

I should have been using capture groups and the r was referring to the capture groups I wanted t keep. Makes sense now.

---

<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: [August 19, 2025, 5:12pm UTC](https://community.mp3tag.de/t/regexp-x-e-r-c/69158/12 "2025-08-19T17:12:44Z")

</div>

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