Super basic question (which I admittedly probably shouldn't post on SO, but here goes): I'm trying to create a regex to match (and exclude from a function) all links that begins with
This has little to do with jQuery or regular expressions. What you're asking about is a CSS selector which has different behaviour altogether. Your problem is with
Note that you don't actually have to escape the slashes here.
let images = document.querySelectorAll('a:not([href^="//images"])'); console.log(images);
<a href="//images/cat.jpg">cat</a> <a href="//images/dog.jpg">dog</a> <a href="/images/fox.jpg">fox</a> <a href="/images/bear.jpg">fox</a>