Heim > Fragen und Antworten > Hauptteil
迷茫2017-04-18 10:47:21
var url = "http://www.xxx.com/1/2";
var reg = /^(http:\/\/){1}(\w+)(\.){1}(\w+)(\.){1}(\w+)(\/\w)*$/g;
var newUrl = "";
if(reg.test(url)){
newUrl = "<a href='" + url + "'>";
}
console.log(newUrl);
//result: '<a href=\'http://www.xxx.com/1/2\'>'