Implement case insensitive replace function