Javascript cyrillic regex

Do I need to check Cyrillic and correct alphabet? encoded urls, this is my curren regex:

if (/^((http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i.test(url)) {
    return true;    
}

      

I need to check urls like: /qaru.site / ... and http: //government.rf/ Any ideas?

+3


source to share


1 answer


You can simply add -

to your character classes:



if (/^((http|https):\/\/)?[a-z-0-9]+([\-\.]{1}[a-z-0-9]+)*\.[a-z-]{2,5}(:[0-9]{1,5})?(\/.*)?$/i.test(url)) {

      

+3


source







All Articles