Parsing, UNIX vs DOS format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
decepticon
Forum Newbie
Posts: 2
Joined: Wed Nov 16, 2005 9:25 am

Parsing, UNIX vs DOS format

Post 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!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
Post Reply