douqiao6015 2013-08-07 14:39
浏览 38
已采纳

RegEx - 如果我们的网站URL包含此,那么

need some regex help for a regex newb.

If our URL contains

SearchBox. 

(SearchBox with the dot on the end) or

SearchBox-Empty

Then, we need to do something. So example matching URLs would be:

http://www.thesite.com/SearchBox.html

or http://www.thesite.com/SearchBox-Empty.html

And a non-matching URL would be:

http://www.thesite.com/SearchBox-Function.html

So, I only want it to be matched when there is not a function being called.

Here is what I have so far:

if((preg_match("@SearchBox\.@",$_SERVER['REQUEST_URI']) || preg_match("@SearchBox\-Empty@",$_SERVER['REQUEST_URI'])) && !empty($_REQUEST['ID']) && is_numeric($_REQUEST['ID'])) {

Thanks for your help!

  • 写回答

3条回答 默认 最新

  • dongping1922 2013-08-07 16:44
    关注

    If I recall correctly, you need to escape your backslashes:

    "/SearchBox(?:\\.|-Empty)/"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大