【问题标题】:php warning No ending delimiter '/' foundphp 警告没有找到结束分隔符'/'
【发布时间】:2013-06-15 18:25:24
【问题描述】:

我的代码如下所示

preg_match_all("/url=http.+?signature.+?\\/", $videosource , $videos);

输出给出:

Warning: preg_match() [function.preg-match]: No ending delimiter '/' found in /...

【问题讨论】:

标签: php preg-match warnings delimiter


【解决方案1】:

你正在逃避最后一个/。试试preg_match_all("/url=http.+?signature.+?\\//", $videosource , $videos);

【讨论】:

    【解决方案2】:

    你可以使用#~代替/作为分隔符

    preg_match_all("~url=http.+?signature.+?\\/~", $videosource , $videos);
    

    【讨论】:

      【解决方案3】:

      我假设你想匹配一个带有反斜杠 \ 的字符串,而不是转义最后一个正斜杠 /。尽量匹配一些末尾长度为0的字符,避免转义最后一个分隔符,例如:

      preg_match_all("/url=http.+?signature.+?\\.{0}/", $videosource , $videos);
      

      【讨论】:

      • 谢谢。我想在“url=http”和“\”之间找到任何东西。你的代码对我不起作用
      猜你喜欢
      • 2012-03-30
      • 1970-01-01
      • 2013-09-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      相关资源
      最近更新 更多