Предположим, у меня есть url = "https://google.com/?q=cats", тогда как мне найти": // "и"? "И заменить их пробелами?
import re url="https://google.com/?q=cats" re.search("\w+",url) # what should I include in this pattern to detect (:// and ?)
Это должно отсортировать вас:
re.sub('://|\?', ' ', url) #https google.com/ q=cats
>>> re.sub(r'(://|\?)', ' ', url) 'https google.com/ q=cats'