Answer the question
In order to leave comments, you need to log in
RegEx for Cyrillic domains?
/(http(s)?:\/\/.)?(www\.)?[-a-z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-z0-9@:%_\+.~#?&//=]*)/ig
Answer the question
In order to leave comments, you need to log in
www.prntscr.com/fmc99r
www.prntscr.com/fmcajx
@([\p{Cyrillic}\p{Latin}\d\.-]{1,64})?\.(?:\x{0440}\x{0444}|ru|su|arpa|info|aero|name|[a-z]{3})@/igu
I use Nod's url module for verification. It parses the address (always with the protocol) and decomposes it into components - protocol, name, port, path, parameters, etc., and immediately converts the name into a panic code - there is no need to invent anything with national characters in the regexp.
function validateUrl(address) {
let url = require('url');
let addressRegexp = new RegExp('^([\\w\\-]+?\\.?)+?\\.[\\w\\-]+?$');
if (address.search(/^(ftp|http|https):\/\//) === -1) { address = 'http://' + address; }
let hname = url.parse(address).hostname;
if (hname.length < 4 || hname.length > 255 || !addressRegexp.test(hname)) {
throw new WrongInput('');
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question