正则表达式:获取//行但不是以http://开头

时间:2015-10-02 02:14:45

标签: php regex

我需要一个正则表达式来获取<%=this.Title%>,但如果它以//开头,它就什么都不做。

示例:

http://

需要抓住:

  

// blabalbal line

     

// catch'm all line(从“// catch”开始)

     

//这是一个链接(以“// this”开头)。

我尝试使用以下变体:'<?php function lol(){ // blabalbal } // catch'm all echo 'http://link.com.br'; // this is a link. '

2 个答案:

答案 0 :(得分:1)

你可以使用php支持的负面lookbehind。

//

如果前面没有http:,则只会与:匹配。根据您的需要,您可能只能router.js离开。

答案 1 :(得分:0)

您可以在此处使用:

[^http:](//.*)

丢弃http字符串,仅捕获以//

开头的字符串