# About using functions with regular expressions

**URL:** <https://community.mp3tag.de/t/about-using-functions-with-regular-expressions/46197>\
**Category:** Support\
**Created:** [August 21, 2019, 9:54am UTC](https://community.mp3tag.de/t/about-using-functions-with-regular-expressions/46197 "2019-08-21T09:54:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jvilar](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jvilar](https://community.mp3tag.de/u/jvilar)\
**Post date:** [August 21, 2019, 9:54am UTC](https://community.mp3tag.de/t/about-using-functions-with-regular-expressions/46197/1 "2019-08-21T09:54:09Z")

</div>

When trying to use functions in the replace argument of the regexp function, the function is applied BEFORE the regular expression. It makes sense as it is the usual composition of functions.

For example, if I try to put minor keys in lower case in german notation, I'm tempted to do

```auto
$regexp(%title%,'(\w+)(?=-moll)',$lower('$1'))

```

Bu this of course transforms $1 to lowercase, that is, the same $1 string, before the regexp function evaluates it.  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/6/6b2a92d6d6ec909da4424367d9db9587f454de62.png)

The question is then, how to apply functions to transform the captures of the regular expression in the replace format?

Thanks!

Jordi

---

<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:** [August 21, 2019, 11:15am UTC](https://community.mp3tag.de/t/about-using-functions-with-regular-expressions/46197/2 "2019-08-21T11:15:46Z")

</div>

I am not sure whether this is a valid example.  
When the $1 returns the input string, then it means it has not found a hit.  
If you want to replace one text constant with another then a simple $replace() would be sufficient - and that is also case sensitive.  
The following expression would turn at least the first letter into a capital one:  
`$regexp(%title%,'(\w+)-(.*)(.*)',$1-\u$2$3)`

---

<div class="post-metadata">

**Author:** ![jvilar](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jvilar](https://community.mp3tag.de/u/jvilar)\
**Post date:** [August 21, 2019, 3:18pm UTC](https://community.mp3tag.de/t/about-using-functions-with-regular-expressions/46197/3 "2019-08-21T15:18:13Z")

</div>

Oh, thanks! The \u (and \l for lowercase) operators are just what I needed!

Jordi

---

<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:** [September 20, 2019, 3:18pm UTC](https://community.mp3tag.de/t/about-using-functions-with-regular-expressions/46197/4 "2019-09-20T15:18:15Z")

</div>

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