It seems, that $0 is not working at all with replace().
It's just interpreted as a normal string.
Can someone verify this?
Yes this is true. $0 is a special thing in InDesign. Therefore I used $1 in the function. There are only minor reasons to use \> instead of \b. The last one is a bit better to remember ;-)