Re: String parsing issue in PHP 4.3.10?

From: Date: Tue, 21 Dec 2004 19:53:53 +0000
Subject: Re: String parsing issue in PHP 4.3.10?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-204876@lists.php.net to get a copy of this message
Steve Brown wrote: > I'm working on a script that will parse through a long string using > regexs to pattern match a certain format. I'm having an issue with a > '?>' in a string being picked up as an end-of-code character, but only No need to run it. ?> can be caught by PHP as the end of PHP mode, no matter where you put it in a string or not. You can get around this by using something like: >// $note_exp = '/\d{1,2} \w{3} \d{4} \d{2}:\d{2}\s?> [!-~ ]+/'; > // COMMENT OUT THIS LINE $note_exp = '/\d{1,2} \w{3} \d{4} \d{2}:\d{2}\s?' . '> [!-~]+/'; Other possible solutions: Use ?\> and PHP inside of "" and maybe PHP will interpret that as what you want. I'm also not a fan of a single \ inside of '' myself, even if the manual has finally said it's kosher. Maybe cuz I'm just old, and remember when that was not specifically allowed in the manual. :-) So I'd use \\ everywhere you have \ currently. Actually, you may be triggering a PHP bug in the string parsing engine, by using \ instead of \\. You do realize that \ *IS* one of the two special characters inside of ''s, the other being ' itself, right?... -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#204876) next »