Answer the question
In order to leave comments, you need to log in
What am I doing wrong in the routine?
Tell me, good people, what am I doing wrong?
/^https:\/\/([\w]+\.)?avito.ru\/[\w-]+\/.+(?!(_[\d]{4,}))$/.test(x)
https://www.avito.ru/moskva/odezhda_obuv_aksessuary/magazin_pizham_kigurumi_na_lubyanke_56545
should return false
https://www.avito.ru/moskva/kvartiry/snimu
-true
Answer the question
In order to leave comments, you need to log in
Maybe you don't need to check the whole line? If all links are correct, then check only the end of the line - you can reverse the line .split('').reverse().join('')
and check only the beginning /^\d{4,}_/
Here is one regular expression for your requirement:
var re = new RegExp('^https?://(\\w+\\.)?avito\\.ru/([^/]+/)+([a-z_]+(?!_\\d{4,}))$');
var t1 = 'https://www.avito.ru/moskva/odezhda_obuv_aksessuary/magazin_pizham_kigurumi_na_lubyanke_56545';
var t2 = 'https://www.avito.ru/moskva/kvartiry/snimu';
re.test(t1) // false
re.test(t2) // true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question