Regex question php preg_match

trying to match the following:

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

the url itself is variable and can contain all kinds !? querystrings and more. Is there an escape function to make it regular?

so I have it 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);

which has problems formatting regular expressions correctly, has been intersecting for several hours. Any help appreciated ...

+3
source share
1 answer

Take a look at preg_quote

+10
source

Source: https://habr.com/ru/post/1779552/


All Articles