This code works on Linux but fails to match on Windows:
if ( preg_match ( "~<meta name='date' content='(.*)'>\n<meta name='time' content='(.*)'>\n<meta name='venue' content='(.*)'>\n~", file_get_contents($filename), $matches) )
...
I guess the line end coding is wrong. How should I modifiy the pattern to be
end-coding independent?
Windows line endings are:
The simplest solution is:
The correct solution probably is:
That said, you probably really should use another method for dealing with HTML & XML. There are parsers built specifically for that.
e.g. http://docs.php.net/manual/en/domdocument.loadhtml.php or http://php.net/manual/en/book.xml.php
On a side note, I haven’t really tested either but iirc, they work. Regex is not something I use much.
EDIT:
Seems to work fine?