Explain replace method and use of regex