Implement simple regex replacement functionality