clean-text
packageclean-text
is a third-party package that is used to pre-process text data to obtain a normalized text representation.
The package can be installed via pip. Check the following command to install the clean-text
package:
pip install clean-text
replace_emails()
methodThe replace_emails()
method is used to replace all emails in the given text with the replacement string.
replace_emails(text, replace_with="<EMAIL>")
text
: This is the text data.replace_with
: This is the replacement string.The method returns the text data where all the emails are replaced by the replacement string.
import cleantextstring = """hello educative - fahim@educative.io - hello edpresso"""new_string = cleantext.replace_emails(string, replace_with="fahim_mail")print("Original String - '" + string + "'")print("Modified String - '" + new_string + "'")
cleantext
package is imported.replace_urls()
method to replace the email in the string with fahim_mail
.