For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > March 2005 > php won't recognize a carriage return









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author php won't recognize a carriage return
brianj7675@yahoo.com

2005-03-30, 3:58 am

php 4.3.6
windows xp

i need to read a file and match a regular expressions with this
pattern: "\r\ntitle"

preg_match($title_reg, $line, $resB);
$find_reg="\r\n$resB[0]";
if (ereg($find_reg, $line2))
echo $resb[0];

now if i put this pattern in powergrep 2.3.2 it recognizes it. however
if i try to use this pattern in my php script i get bupkis nada nothing
zero. i've tried putting the carriage return in () and in [] but i get
nothing still. when i print the pattern to my browser i see a space in
front of my title showing me that php is recognizing something but it
does not print the \r\n so i'm pretty sure that is why i'm not getting
a match.now i know these are not printable characters but they are in a
string so they should print to the screen.
So my assumption is that php is erasing or translating /r/n into
something so that it does not match my pattern.

brianj7675@yahoo.com

2005-03-30, 3:58 am

awsnering my own question here/
ok i found out why duh
it would not recognize a carriage return because that return was on the
line before and it could not see that line because i am reading one
line at a time.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com