V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
world
V2EX  ›  问与答

求以正则表达式

  •  1
     
  •   world · 2015-04-14 11:50:48 +08:00 · 1941 次点击
    这是一个创建于 3293 天前的主题,其中的信息可能已经有所发展或是发生改变。

    先贴上源码
    add_filter('the_content','baezone_the_go_url',999);
    function baezone_the_go_url($content){
    preg_match_all('/href="(.*?)"/',$content,$matches);
    if($matches){
    foreach($matches[1] as $val){
    if( strpos($val,home_url())===false ) $content=str_replace("href=\"$val\"", "href=\"" . get_bloginfo('wpurl'). "/go?url=" .base64_encode($val). "\"",$content);
    }
    }
    return $content;
    }

    现在的匹配规则是匹配文章内所有的链接,但是考虑到需求,我想在匹配文章内链接的基础上加一个例外,不匹配图片上的链接。
    正则表达不会写,求各位大大指点一下

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3773 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 05:05 · PVG 13:05 · LAX 22:05 · JFK 01:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.