Hi all.. im racking my brain here and its late so maybe im missing something. im reading an htdoc using fopen/fread into a string var $contents i want to replace the entire <title> meta tag from start to end.. $file = "index.php"; $h = fopen($file, "r"); $contents = fread($h, filesize($file)); fclose($h); eregi_replace("<title>[a-zA-Z0-9._-]+</title>","<title>new title tag</title>",$contents); nothings happening... is it possible that its gettings stopped by other characters in the pattern im not expecting or is there an inherent error-- im new to reg ex thanks Logan
Here is a refresher info for your Logan: http://forums.digitalpoint.com/showthread.php?t=1329498 Problem with your expression is that you aren't escaping / character. This should work: "<title>.*<\/title>" Peace,
In regular expressions you should always escape the meta characters. Sometimes you forget some, so i advise you to use this simple function: $pattern = ''; // the regexp that you want to use $pattern = addcslashes($pattern, '^[.${*(\\+)|?<>');