how find value of javascript variable with regex?

前端 未结 1 1278
北海茫月
北海茫月 2021-01-27 14:44

I want RegEx in php that find value of js variable in my html page. Like this:

varName = \"http://sample.com\";
相关标签:
1条回答
  • 2021-01-27 15:03

    Something like that... but it could be extremely more complicated with the complexity of the js code

    <?
    $varname = "varName";
    preg_match('/'.$varname.'\s*?=\s*?(.*)\s*?(;|$)/msU',$html,$matches);
    
    if(count($matches>1)) {
        print($matches[1]);
    }
    
    
    ?>
    
    0 讨论(0)
提交回复
热议问题