Hi all, this is really bugging me. I have a regular expression i am running on a text file i am opening, the regexp works in my regexp test suite but not when i run it in php. regular expressions are not my friend so i'm not sure if this is obvious or not but i would really appreciate some help.
In short my regexp should detect any line inside the opened text file - lines.txt - that begins with STRTOMATCH and return the whole line. Nothing is being returned tho unless i make the file 1 line long, is it maybe not detecting the end of lines ??
<?
$filename = "lines.txt";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);
if (preg_match('/^.*(^STRTOMATCH ).*$/', $contents, $regs)) {
$result = $regs[0];
} else {
$result = "n";
}
echo $result;
?>
thanks