带有regex preg_replace的php标记
我有一个url,比如说: 图像和标签带有regex preg_replace的php标记,php,preg-replace,Php,Preg Replace,我有一个url,比如说: 图像和标签 <img f="/example2"></img> <img f="example3"></img> <img f="http://example4.com"></img> <img f="https://example5.com"></img> 因此,如果我在上面的标记中使用此代码,输出将是: $regex = "-(src\s*=\s*['\"])(((?!
<img f="/example2"></img>
<img f="example3"></img>
<img f="http://example4.com"></img>
<img f="https://example5.com"></img>
因此,如果我在上面的标记中使用此代码,输出将是:
$regex = "-(src\s*=\s*['\"])(((?!'|\"|http://|https://).)*)(['\"])-i";
不确定我是否在跟踪您,但是,f=“(?!https?:/)/?(.*)”
呢?我在regex中使用了f
,因为这就是您的示例所使用的。这不是我要找的,假设我想要如果src在开始时没有/a,那么我们将在开始时添加url?
<img f="https://stackoverflow.com/example1//example2></img>
<img f="https://stackoverflow.com/example1/example3></img>
<img f="http://example4.com/"></img>
<img f="https://example5.com/"></img>