javascript - Can't figure out regex match, how far off am I? -
super basic question (which admittedly shouldn't post on so, here goes): i'm trying create regex match (and exclude function) links begins //images
, cannot life of me work.
right have:
$('a:not([href^=/\/\images])').each(function(){
but since isn't correct, , don't know begin looking set straight, i'm asking advice. i'm used escaping strings etc., seems quite different(?).
also, tried using http://regexr.com/ , https://txt2re.com/ (didn't understand how work latter...) feel have no clue put @ point since i'm guessing.
again, sorry posting such basic question, right gibberish me, sadly.
this has little jquery or regular expressions. you're asking css selector has different behaviour altogether. problem /\/\
vs \/\/
.
note don't have escape 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>
Comments
Post a Comment