正则表达式在线测试
正则表达式在线测试:
https://c.runoob.com/front-end/854/?optionGlobl=global
code
onLoad: function(option) {
// 获取当前页面地址,如http://localhost:8080/admin/index
let wPath = window.document.location.href;
let doMain = window.location.host;
var patternOld =/(.*)\.saikr\.com/;//正则表达式
var pattern = /(?<=[\.]).*?(?=[\.])/; //正则表达式 ..之间的字符
var pattern2 =/\w*?(?=[\.])/; //正则表达式,没有www的情况
if(doMain.match(pattern) == 'saikr'){
console.log("saikr"+doMain.match(patternOld)[1]);
this.getContestConfig(doMain.match(patternOld)[1]);
}
else if (doMain.match(pattern2) == 'www') {
console.log("wwww"+doMain.match(pattern));
this.getContestConfig(doMain.match(pattern));
} else{
console.log("无wwww"+doMain.match(pattern2));
this.getContestConfig(doMain.match(pattern2));
}
},
原文链接:https://blog.csdn.net/wenxingchen/article/details/125868986