I'm currently struggling with regex. I'm trying to substitute every website ending with a ".com" except one, that is "crypto.com" as it's not a website per se but also the name of a cryptocurrency.
Let's take this sentence:
"Here are my favorite things: crypto.com, polo.com, cryp.com and google.com"
Inspired by this answer, this is my Python regex:
r"(\w+\.)?crypto\.com"
The problem, using https://regex101.com to test it out, is that it's capturing only the crpyto.com, but not the others (which is what I want to do).
Can anyone tell me how to proceed? Thank you!
Expected code:
text = "Here are my favorite things: crypto.com, polo.com, cryp.com and google.com"
text = re.sub(r"(\w+\.)?crypto\.com", '', text )
Expected output:
"Here are my favorite things: crypto.com,, and "
re.sub(r'\s*\b(?!crypto\.)\w+\.com\b', '', text)rstrip(',')in Python code.