I have implemented tag replace functionality in libnjb
and it runs perfectly on my machine. Here is a patch.
You will probably want to indent my code, but apart
from that I have tried to follow your way of coding.
I have tried repeatedly to register a sourceforge
account but always fail miserably.