--- David T-G <[EMAIL PROTECTED]> wrote: > 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! > >
> ATTACHMENT part 2 application/pgp-signature K, my fault (but the script is functional in both variants - tested in SciTE). That is 2nd faulty response sended by me to list. At the 3rd I will unsubscribe :-) HAND __________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php