Regex:获取//行,但不以http://.开头


Regex: Get // line but not if start with http://

我需要一个正则表达式来获得//,但如果它从http://开始,它什么也不做。

的例子:

<?php 
function lol(){
// blabalbal
} // catch'm all
echo 'http://link.com.br'; // this is a link.

需要捕获:

//blabalbal line

//catch"

//这是一个链接(从"//this"开始)

我在尝试:' /'/'/(.*)$ '的变化

你可以使用php支持的反向查找

(?<!http:)(//.*)

如果前面没有http:,则只匹配//。根据您的需要,您可以仅使用:

这里你可以这样使用:

[^http:](//.*)

丢弃以http开头的字符串,只捕获以//开头的字符串