【发布时间】:2012-05-16 15:39:22
【问题描述】:
我希望 php 中的 RegEx 在我的 html 页面中找到 js 变量的值。 像这样:
varName = "http://sample.com";
【问题讨论】:
-
那么,您想提取存储在 PHP 变量中的 HTML 页面中的 JavaScript 变量的值吗?
标签: javascript regex variables find
我希望 php 中的 RegEx 在我的 html 页面中找到 js 变量的值。 像这样:
varName = "http://sample.com";
【问题讨论】:
标签: javascript regex variables find
类似的东西......但是由于 js 代码的复杂性,它可能会变得非常复杂
<?
$varname = "varName";
preg_match('/'.$varname.'\s*?=\s*?(.*)\s*?(;|$)/msU',$html,$matches);
if(count($matches>1)) {
print($matches[1]);
}
?>
【讨论】: