Help with regular expressions


I want to search all my site’s html files for the example URL below: (anything could be after the forward slash “/”)

If some results have “eng” or “fra” immediately proceeding the domain (i.e. below) then I don’t want those URLs to be included in the results:

How can this be done using regular expressions?


this might/should do it:

if( preg_match("/www\\.example\\.ca/(?!(eng/|fra/))/i", $string)) {
   // match

one correction: slashes need escaping, so:

if( preg_match("/www\\.example\\.ca\\/(?!eng\\/|fra\\/)/i", $string)) { 
   echo '<p>match</p>';
} else {
	echo '<p>no match</p>';