![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Bollocks
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
|
Regex to strip HTML comments
Trying to strip HTML comments from a web page, someone else must have done this.
I'm using Code:
$page = preg_replace('/<!--(.|\s)*?-->/', '', $page
__________________
Interserver unmanaged AMD Ryzen servers from $73.00 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Industry Role:
Join Date: Jul 2009
Posts: 217
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Bollocks
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
|
Quote:
__________________
Interserver unmanaged AMD Ryzen servers from $73.00 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Bollocks
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
|
Tht's probably what I started with but surely will just catch everything between the first opening comment tag and the last closing one?
__________________
Interserver unmanaged AMD Ryzen servers from $73.00 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
Confirmed User
Join Date: Oct 2008
Posts: 344
|
Quote:
Edit: When is your regex breaking? The /<!--(.|\s)*?-->/ one? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Porn Meister
Industry Role:
Join Date: Feb 2005
Posts: 16,443
|
I was looking all through my old scripts for that to help you, but I think you've got it now.
__________________
43-922-863 Shut up and play your guitar. ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Bollocks
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
|
Don't know, on most pages it happily strips out comments but on some it just returns null and I haven't figured out what the difference is with those pages yet.
EDIT just spotted this comment in the PHP user manual: "As a pertinent note, there's an issue with this function where parsing any string longer than 94326 characters long will silently return null. So be careful where you use it at. " Could be it.
__________________
Interserver unmanaged AMD Ryzen servers from $73.00 |
![]() |
![]() ![]() ![]() ![]() ![]() |