replace by RegExp

smarter buffer method