专业编程基础技术教程

网站首页 > 基础教程 正文

正则表达式获取两个标识中间的内容

ccvgpt 2024-07-20 11:54:04 基础教程 11 ℃

正则表达式在线测试

正则表达式在线测试:

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

Tags:

最近发表
标签列表