如果字符串或文本包含特定域,例如
,我想跳过并function updateXDiv(myDate) {
if (lastZoomDate <= myDate) {
document.getElementById('x-min').innerHTML = xAxis.scale().domain()[0];
document.getElementById('x-max').innerHTML = xAxis.scale().domain()[1];
}
}
返回0
preg_match()
如果有$var="for see our post visit phyteachers.com |click now";
if(preg_match('(((https?|ftps?)\:\/\/)?((www([0-9]+)?)\.)?.*\.[a-zA-Z0-9](\/)?((?!.*phyteachers\b).*))','$var')==0){
echo "ok";
}
或http://phyteachers.com
或http://www.phyteachers.com
或https://www.phyteachers.com
或https://phyteachers.com
或www.phyteachers.com
,则返回phyteachers.com
。< / p>
答案 0 :(得分:1)
我的以下模式可能会有所改进,但它应该符合您的目的。
~(?:(?:ht|f)tps?:/{2})?(?:w{3}\d*\.)?(?:phyteachers\.com(*SKIP)(*FAIL)|\S+\.[a-z\d]+/?\S*)~
https://regex101.com/r/iZ9HRQ/6
有关模式组件的正式术语,请参阅演示链接。否则,我会提供非正式的解释......
(?: # start optional non-capturing group
(?:ht|f)tps? # match http, https, ftp, ftps
:/{2} # match colon then two slashes
)? # end optional group (none of this HAS to exist)
(?: # start optional non-capturing group
w{3}\d*\. # match www then zero or more digits, then optiona
)? # end optional group
(?: # start non-capturing group
phyteachers\.com(*SKIP)(*FAIL) # abort match if found
| # or
\S+\.[a-z\d]+/?\S* # see the demo, too involved to explain in limited space
) # end non-capturing group