用于添加异常的正则表达式代码-python

用于添加异常的正则表达式代码-python,python,regex,Python,Regex,我从数据框中提取了一个包含网站链接的专栏,以查找网站: csv_document = pd.read_csv(csv_doc) tweets = csv_document.Tweet count = {} for tweet in tweets: matches = re.findall(r'http[s]?://([^\/]*)',tweet) for match in matches: count[match] = count.get(match,

我从数据框中提取了一个包含网站链接的专栏,以查找网站:

csv_document = pd.read_csv(csv_doc)
tweets = csv_document.Tweet
    
count = {}

for tweet in tweets:
    matches = re.findall(r'http[s]?://([^\/]*)',tweet)
    for match in matches:
        count[match] = count.get(match,0) + 1
正则表达式代码允许我识别以“http | https'+':/”开头的所有字符串。 现在我想在regex代码中添加一种方法,以避免所有以
www.
开头的Web站点,即使它们有
http://
https://

我试过:
(?!www.)

我不工作。如何添加此异常

我看了一下regex网站,没有找到解决方案


谢谢。

您需要将
(?!www\)
放在协议
https?:/
r'https?:/(?!www\)([^\/]*)”
@HaoWu,谢谢!我没走那么远。我想它应该落后了。
    matches = re.findall(r'http[s]?://([^\/]*)(?!www.)',tweet)