开发者

regex question php preg_match

开发者 https://www.devze.com 2023-01-29 15:31 出处:网络
trying to match the following: rawurl=\"http://www.domain.com/page/etc/\" the URL itself is variable and could contain all sorts! ? querystrings and more.

trying to match the following:

rawurl="http://www.domain.com/page/etc/"

the URL itself is variable and could contain all sorts! ? querystrings and more. Is there an escape function to make it regex safe?

so I have this so far

            $var is already defined..
            $url = "www.adomain.com/with/extras/"
            $url = str_replace(" \/ ","/",$url);  // maybe more needed here. 
            $pattern = "/rawurl\=\"http\:\/\/$url/";                
            preg_match($pattern, $var, $out);

having problems formatting t开发者_如何学Che regex correctly, have been going cross eyed now for several hours. Any help appreciated...


Take a look at preg_quote

0

精彩评论

暂无评论...
验证码 换一张
取 消