changed regex a little to permit empty replaces