我有一个问题,我不能允许一个单词+任何类型的url,但是我想忽略包含url hacking.com的文本
Valid: Buy Cell Phone at https://storeOfficial.com
Valid: Buy Cell Phone at https://store.com
Invalid: Buy Cell Phone at https://hacking.com
Invalid: Buy Cell Phone at https://storeOfficial.com and https://hacking.com我的雄鹰:
^(?=[\w\W]*([\W|_]+|^)(Cell Phone\b|cell phone\b|CELL PHONE\b).*(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))发布于 2022-05-06 18:18:58
您可以使用
(?i)^.*\bCell Phone\b(?!.*(?:ht|f)tps?:\/\/(?:[^.]*\.)?hacking\.com(?=\/|$)).*(?:ht|f)tps?:\/\/\S+见regex演示。详细信息
(?i) -不区分大小写的标志^ -字符串的开始.* -任何文本\bCell Phone\b -一个完整的词Cell Phone(?!.*(?:ht|f)tps?:\/\/(?:[^.]*\.)?hacking\.com(?=\/|$)) -如果除行中断字符之外的任何零个或多个字符,然后是协议,然后是除.字符和.字符以外的任何零或多个字符的可选序列,则会导致匹配失败,然后是hacking.com字符串,要么在字符串的末尾,要么紧接着跟着/字符。.* -任何文本(?:ht|f)tps?:\/\/\S+ - http://,https://,ftps://或ftp://,然后是一个或多个非空白字符.https://stackoverflow.com/questions/72145792
复制相似问题