English 中文(简体)
PHP perl regular expression - URL not before by Equal sign and possible one or Doublequote
原标题:PHP perl regular expression - URL not preceded by equal sign and possible single or double quote

我试图制造一种与“URL”相对应的经常表达,这种表达方式以前没有平等标志,也没有一个或一个单一的或两倍的(选择)忽略白人空间。 下面的法典有一处错误:Warning: preg_replace(): 汇编失败:表面上的说法没有固定的长度以抵消0

我知道,我定期表达是完美无缺的,但我更侧重于如何做消极的眼光,或如何以其他方式表达。

例如,在以下编码中,在配对器中,应输出,但不是其他URLs。 我如何能够这样做? 下面的法典提供了警告,没有填满配量变量。

PHP 法典:

$html = "
http://www.url1.com/
=   http://www.url2.com/
 http://www.url3.com/
<a href= http://www.url4.com/ >Testing1</a>
<img src= https://url5.com >Testing2</a>";

$url_pregex =  ((http(s)?://)[-a-zA-Z()0-9@:%_+.~#?&;//=]+) ;
$pregex =  (?<!\s*=\s*[ "]?\s*) .$url_pregex;

preg_match_all( ` .$pregex. `i , $html, $matches);

echo "Matches<br><pre>";
var_export($matches);
echo "</pre>";

PHP中的Perl Regex使用“而不是”:

 `(?<!\s*=\s*[ "]?\s*)((http(s)?://)[-a-zA-Z()0-9@:%_+.~#?&;//=]+)`i 
问题回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...