简体   繁体   English

如何从 userContent.css 的正则表达式中排除两个术语?

[英]How can I exclude two terms from regex in userContent.css?

I'm trying to modify certain aspects of the CSS code for my Google search results page.我正在尝试为我的 Google 搜索结果页面修改 CSS 代码的某些方面。 I'm doing this by editing my userContent.css file in Firefox.我通过在 Firefox 中编辑我的userContent.css 8CBA22E28EB17B5F5C6AE2A266AZ 文件来做到这一点。

I'm trying to modify the main results page ( https://www.google.co.uk/search?q=SSD ).我正在尝试修改主要结果页面( https://www.google.co.uk/search?q=SSD )。

But not on the images page ( https://www.google.co.uk/search?q=SSD&tbm= isch ) or the shopping results page ( https://www.google.co.uk/search?q=SSD&tbm= shop ).但不在图片页面 ( https://www.google.co.uk/search?q=SSD&tbm= isch ) 或购物结果页面 ( https://www.google.co.uk/search?q=SSD&tbm =商店)。

Based on the answer provided here , I've added this code:根据此处提供的答案,我添加了以下代码:

@-moz-document regexp('https://www\\.google\\.co\\.uk.*(?.isch|shop).*')

But it doesn't seem to work to exclude isch or shop .但排除ischshop似乎不起作用。

Can someone please help?有人可以帮忙吗?

Thanks谢谢

Your pattern matches those urls because after matching .uk you use .*(?!isch|shop) which will first match until the end of the string due to .*您的模式与这些网址匹配,因为在匹配.uk之后,您使用.*(?!isch|shop)它将首先匹配到字符串结尾,因为.*

Then asserts if what is on the right is not isch or shop which will be true as all characters are already matched.然后断言右边的内容是否不是 isch 或 shop 这将是真的,因为所有字符都已经匹配。

One option could be to use the negative lookahead (?.?*=(::isch|shop)$) after matching .uk/ to check if the url does not end on =isch or =shop using .* in the negative lookahead followed by $ to assert the end of the string.一种选择可能是在匹配.uk/之后使用负前瞻(?.?*=(::isch|shop)$)来检查 url 是否未在 =isch 或 =shop 上结束,在负前瞻中使用.*后跟$断言字符串的结尾。

https://www\.google\.co\.uk/(?!.*=(?:isch|shop)$).*$

Regex demo正则表达式演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM