Marius, et al --
...and then Marius Dascalu said...
%
% --- Justin French <[EMAIL PROTECTED]> wrote:
% >
% > This isn't working:
% > $text = preg_replace('/<!--(.*)-->/','',$text);
...
%
% Hi, Hello! % % You must escape "-" (minus sign) because is a % meta-character for regular expressions. See What? No. % http://www.php.net/manual/en/pcre.pattern.syntax.php. From that same link: Part of a pattern that is in square brackets is called a "character class". In a character class the only meta-characters are: \ general escape character ^ negate the class, but only if the first character - indicates character range ] terminates the character class So you only have to worry about a minus if you're in a [a-z] range, and even then you can put a minus in without having to resort to backslashes. % Your line of code might be: % % <CODE> % $text = preg_replace('/<!\-\-(.*)\-\->/','',$text); % </CODE> Then, again, it might not ;-) % % This line of code, if you are parsing HTML file row by % row, strips only "one line" comments. Comments spanned % on multiple lines are unaffected. Agreed. Let's leave that to the student to work out, shall we? :-) % % HTH % % Marius HTH & HAND :-D -- David T-G [EMAIL PROTECTED] http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgpAVyM41dMQO.pgp
Description: PGP signature

