# \[X\] Replace with Regular Expression

**URL:** https://community.mp3tag.de/t/x-replace-with-regular-expression/8140
**Category:** No Bugs
**Created:** [March 23, 2009, 8:59pm UTC](https://community.mp3tag.de/t/x-replace-with-regular-expression/8140 "2009-03-23T20:59:27Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [March 26, 2009, 7:14pm UTC](https://community.mp3tag.de/t/x-replace-with-regular-expression/8140/3 "2009-03-26T19:14:47Z")

</div>

> [@loveMusique](#):
>
> Execution examples:
> 
> 1. Field is empty — Result: Field is still empty.
> 2. Field is _not_ empty — Result: Field's content = "Jamendo"

I'm using boost::regex as regular expression library which matches the null string when using the dot notation. My interpretation of this behaviour is, that a null string has neither a line begin ^ nor a line end $ so that the empty string isn't matched.

If the source string isn't empty, everything works as expected (also the null string isn't matched due to ^ and $).

> [@Sebastian Mares](#):
>
> Something else - why does using ".\*" as expression lead to the replacement string to be inserted twice?

This should now be very straightforward given the explanation above. Both the null string and the actual string are matched resulting in a duplication of the replace string.

Evil beasts, those regular expressions ![:rolleyes:](https://community.mp3tag.de/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif ":rolleyes:")

---

_[View the full topic](https://community.mp3tag.de/t/x-replace-with-regular-expression/8140)._
