2023年6月25日发(作者:)
url正则有测试⽤例⽅法// 建议的正则function isURL(str){ return !!(/(((^https?:(?:)?)(?:[-;:&=+$,w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,w]+@)[A-Za-z0-9.-]+)((?:[+~%.w-_]*)???(?:[-+=&;%@.w_]*)#?(?:[w]*))?)$/g);}//jb51function IsURL(str_url){ var strRegex = "^((https|http|ftp|rtsp|mms)?://)" + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@ + "(([0-9]{1,3}.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184 + "|" // 允许IP和DOMAIN(域名) + "([0-9a-z_!~*'()-]+.)*" // 域名- www. + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]." // ⼆级域名 + "[a-z]{2,6})" // first level domain- .com or .museum + "(:[0-9]{1,4})?" // 端⼝- :80 + "((/?)|" // a slash isn't required if there is no file name + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; var re=new RegExp(strRegex); //() if ((str_url)){ return (true); }else{ return (false); }}测试控制台输出结果
发布者:admin,转转请注明出处:http://www.yc00.com/web/1687678781a30878.html
评论列表(0条)