正则表达式 //正则表达式 匹配 127.0.0.1和192.168.1.101,var re=/(\d{1,3}\.){3}\d{1,3}/g;var str="fjskfjsl fjkdsjfkls fjklsfjlsd127.0.0.1fjksldfjafjio jfk192.168.1.101sljfs fsdjfkldsfjsklfsklffjoijfoiaf/asfjs fed jfjf jf sdjfsi
//正则表达式 匹配 127.0.0.1和192.168.1.101, var re=/(\d{1,3}\.){3}\d{1,3}/g; var str="fjskfjsl fjkdsjfkls fjklsfjlsd127.0.0.1fjksldfjafjio jfk192.168.1.101sljfs fsdjfkldsfjsklfsklffjoijfoiaf/asfjs fed jfjf jf sdjfsi jfi jafis function dd (){ }afjsdiajf iosa function abc(){} jfisjad fjsaiofjaoissfaddedfds"; resultRe=str.match(re); console.log(resultRe); //正则表达式 匹配 javaScript函数 function dd (){ }和function abc(){} var fn=/function\s\w*\s?\(\s?\)\{\s?\}/g; resultFn=str.match(fn); console.log(resultFn);数组合并
function fn(arr1,arr2){ var arr=[].concat(arr1,arr2); //var arr=arr1.join(arr2); console.log(arr); } fn([1,2,3],[4,5,6]);随机数
function shaizi(num){ var rd=Math.random(); var result=Math.ceil(rd*num*6); console.log(result); } shaizi(1); //shaizi(2);