正则 – 青春部落,流年似水 http://www.youthtribe.com 青春是一场远行,总记不起来时的路。 Fri, 11 Jan 2019 07:31:15 +0000 zh-CN hourly 1 https://wordpress.org/?v=6.1.7 正则 – 青春部落,流年似水 http://www.youthtribe.com/archives/1585 http://www.youthtribe.com/archives/1585#respond Fri, 09 Sep 2016 06:49:54 +0000 http://www.youthtribe.com/?p=1585 var reg = /^\d+(\.\d+)?$/;
if (!reg.test(new_score)){
alert('输入不合法,更改无效');
return false;
}

js正则判断字符串是否为正确的浮点数

]]>
http://www.youthtribe.com/archives/1585/feed 0
正则 – 青春部落,流年似水 http://www.youthtribe.com/archives/1387 http://www.youthtribe.com/archives/1387#respond Mon, 10 Nov 2014 05:34:43 +0000 http://www.youthtribe.com/?p=1387

php中文正则-utf8下可用

]]>
http://www.youthtribe.com/archives/1387/feed 0
正则 – 青春部落,流年似水 http://www.youthtribe.com/archives/1385 http://www.youthtribe.com/archives/1385#respond Mon, 10 Nov 2014 05:33:18 +0000 http://www.youthtribe.com/?p=1385 PHP 邮箱验证正则表达式



]]>
http://www.youthtribe.com/archives/1385/feed 0
正则 – 青春部落,流年似水 http://www.youthtribe.com/archives/1373 http://www.youthtribe.com/archives/1373#respond Wed, 15 Oct 2014 09:23:18 +0000 http://www.youthtribe.com/?p=1373 因为我对这个cmathresult模版类不懂,所以我的方法就是,每找到一个匹配项,那就把他替换为空,这样循环下去,直到得不到正则匹配项为止。

//just for google
bool CURLCollectorDlg::GetMatchCString2(CString strSearch, CString strBegin, CString strEnd ,CStringArray &arr)
{
	CString strReturn;
	//MessageBox("str" + strSearch);
	std::string str(strSearch.GetBuffer());
	//正则规则
	std::string strbegin,strend,strreg;
	strbegin = strBegin.GetBuffer();
	strend = strEnd.GetBuffer();
	strreg = "(.*?)";
	strreg = strbegin + strreg + strend;
	std::regex reg(strreg);
	//flag
	std::regex_constants::match_flag_type f = std::regex_constants::match_any;
	//存放匹配出来字符串
	std::match_results mr;

	if (std::regex_search(str,mr,reg,f))
	{
		AddStatus("匹配成功");
	} 
	else
	{
		AddStatus("匹配失败");
		return false;
	}
        //这个while循环是核心代码
	while(std::regex_search(str,mr,reg,f))
	{
		std::string s(mr.str());
		strReturn = s.c_str();
		//开始替换
		CString newstr;
		newstr = str.c_str();
		newstr.Replace(strReturn,"");
		str = newstr.GetBuffer(0);
		//
		strReturn.Replace(strBegin,"");
		strReturn.Replace(strEnd,"");
		strReturn.Replace("","");
		strReturn.Replace("","");
		//AddOneURL("匹配到的网址:" + strReturn);


		//str = str.replace(s,"",);
		arr.Add(strReturn);



	}
	return false;
	
}
]]>
http://www.youthtribe.com/archives/1373/feed 0