Page 1 of 1
regex quickie
Posted: Tue Jan 16, 2007 3:10 pm
by alex.barylski
Code: Select all
$html = preg_replace("/<!-- START_NAV_MENU -->(.+)<!-- END_NAV_MENU -->/", $menu_html, $html);
1) Will this find a single occurance of the HTML comments and everything inbetween it?
2) When it replaces the comments stay put or do I have to wrap $menu_html with tags again?
Cheers

Posted: Tue Jan 16, 2007 3:14 pm
by John Cartwright
Have you tried?
Posted: Tue Jan 16, 2007 3:18 pm
by alex.barylski
Yes...nothing happened...
Latest:
Code: Select all
$html = preg_replace("/\<\!\-\- START_NAV_MENU \-\-\>(.*)\<\!\-\- END_NAV_MENU \-\-\>/", $menu_html, $html);
This appears to be match other comments and reproducing/replicating those a few times???

Posted: Tue Jan 16, 2007 3:34 pm
by feyd
".*?"
"s" modifier too. No need for all the escaping, they aren't metacharacters.
Posted: Tue Jan 16, 2007 3:41 pm
by alex.barylski
feyd wrote:".*?"
"s" modifier too. No need for all the escaping, they aren't metacharacters.
I didn't think so...but I had no other idea WTF was going on and figured they didn't hurt

but i'll remove them for sure thanks
