Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 预匹配url模式_Php_Javascript_Preg Match_File Get Contents - Fatal编程技术网

Php 预匹配url模式

Php 预匹配url模式,php,javascript,preg-match,file-get-contents,Php,Javascript,Preg Match,File Get Contents,由于我找不到问题的确切答案,我决定请求帮助将我的问题发布在这里。因此,我有一个页面内容,通过file\u get\u contents获得,并希望preg\u匹配此url: http://sample.com/Last/LastSearch.ashx?q=cnt=1&day=5&keyword=sample&location=15&view=v 从 请帮帮我。为什么不使用DOM?这就是它的目的 如果您坚持使用正则表达式,请尝试(使用PHP) if(preg_

由于我找不到问题的确切答案,我决定请求帮助将我的问题发布在这里。因此,我有一个页面内容,通过
file\u get\u contents
获得,并希望
preg\u匹配此url:

http://sample.com/Last/LastSearch.ashx?q=cnt=1&day=5&keyword=sample&location=15&view=v



请帮帮我。

为什么不使用DOM?这就是它的目的

如果您坚持使用正则表达式,请尝试(使用PHP)


if(preg_match('/为什么不使用DOM?这就是它的用途

如果您坚持使用正则表达式,请尝试(使用PHP)


如果(preg_匹配('/只要url总是以http://开头,那么您可以在preg_匹配中使用以下表达式:

(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)

只要url总是以http://开头,您就可以在preg_匹配中使用以下表达式:

(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)

(f|ht){1}
=
(f|ht)
{1}
是隐含的。在我的情况下如何使用它?
(f|ht){1}
(f|ht)
{1}
是隐含的。在我的情况下如何使用它?明白了:
preg\u match('/get:
preg\code>preg\u match('/
var myregexp = /<a href="javascript:LastURL\('([^'])*'/;
var match = myregexp.exec(subject);
if (match != null) {
    result = match[1];
} else {
    result = "";
}
(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)