Changed replacechar to accept a variable as a replacement