Page 1 of 1

Parsing, UNIX vs DOS format

Posted: Wed Dec 21, 2005 11:20 am
by decepticon
Hi,

Not sure if anybody has run into this problem before, but I am having problems parsing PHP a file that was compiled in UNIX.

I'm parsing a PHP file using regular expressions, and outputting the results to an XML file. It works fine if the file I am parsing is saved in any windows text editor, but if the file is compiled in UNIX, that is where I run into problems.

So what I did was used a program that ran a 'unixtodos' command on the PHP file I was parsing, and then my script worked perfectly!

However, that was just a workaround, and I want to get to the root of the problem.

Any suggestions would be helpful...

Thanks!

Posted: Wed Dec 21, 2005 11:31 am
by Chris Corbyn
Linux uses \n to mark the end of each line, whereas windows uses \r\n --- sounds like you need to update you're regex to account for this.

There's perhaps something in your regex like \r\n that you need to change to (\r)?\n ;)