Posts

Showing posts with the label nsregularexpression

Regular expression to get internal links only

Image
Clash Royale CLAN TAG #URR8PPP Regular expression to get internal links only I am trying to get internal links only with the following code. $domain="http://www.nydailynews.com"; $data = file_get_contents($domain); $content=preg_match( '(.*'.$domain.'.*)|(^/.*$)', $domain, $matches ); but getting this error Warning: preg_match(): Unknown modifier '|' in C:xampphtdocscrawlcrawlindex.php on line 4 what should be the regular expression for that so I can get sub pages of a website? You need to add delimiters around your regex like this: /(.*' . $domain . '.*)|(^/.*$)/ . What do you mean with "sub-pages" of a website? The path? Take a look at parse_url() then. – Heyne 1 hour ago /(.*' . $domain . '.*)|(^/.*$)/ parse_url() ...