Using regex in selector to exclude certain items

Can I use Regex to exclude specific selector results?
For example, I select product categories from a menu using

li.main-navigation-level1-item > span > a[href]

but I want to exclude any result that contains the word "wine"

Is this possible?
Thanks

@beau Yes, it is possible by applying jQuery selectors - ':not' & ':contains'

li.main-navigation-level1-item > span > a[href]:not(:contains('Wine'))

Please, note that this is case sensitive.

Learn more: Selectors | jQuery API Documentation

Brilliant!

Is this in the documentation as I couldn't find anything about it and it's really useful!

Also, how can I add "wine" OR "tobacco"?

li.main-navigation-level1-item > span > a[href]:not(:contains('Wine')):not(:contains('wine')):not(:contains('tobacco'))

1 Like