PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Aug 22, 2019 3:20 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Fri Aug 27, 2004 9:07 am 
Offline
Forum Contributor

Joined: Wed Jun 23, 2004 12:56 pm
Posts: 126
Location: Prague, Czech Republic


Last edited by tomfra on Fri Aug 27, 2004 1:15 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 10:20 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
untested
Syntax: [ Download ] [ Hide ]
preg_replace('#onload\s*=\s*([\'"]?).*?\\1\s+#i','',$text);


Last edited by feyd on Wed Aug 24, 2005 7:44 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 12:00 pm 
Offline
Forum Contributor

Joined: Wed Jun 23, 2004 12:56 pm
Posts: 126
Location: Prague, Czech Republic


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 12:20 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
you could create your own strip_tags.. :D (untested)
Syntax: [ Download ] [ Hide ]
<?php



$stripped = preg_replace('#</?.*?>#','',$text);



?>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 12:50 pm 
Offline
Forum Contributor

Joined: Wed Jun 23, 2004 12:56 pm
Posts: 126
Location: Prague, Czech Republic
This seems to be working too. I only made a little modification:

Syntax: [ Download ] [ Hide ]
$stripped = preg_replace('#</?.*?\>#','',$text);


I don't know if will will not alter the functionality in some situations though because I know next to nothing about regex. I added backslash because my PsPad couldn't highlight the code properly because it though PHP code was ended with the ? &gt; tag.

One has to wonder why the strip_tags function even exists in PHP when it's buggy and can be replaced with a one-liner. I guess it may be because strip_tags is faster?

Tomas


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 12:57 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
strip_tags is there for people who know nothing about the regular expression functions. It is also useful because it is faster (because of compiled code) .. it also will ignore tags, if you send them with it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 4:09 pm 
Offline
Forum Contributor

Joined: Wed Jun 23, 2004 12:56 pm
Posts: 126
Location: Prague, Czech Republic


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 4:27 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 5:11 pm 
Offline
Forum Contributor

Joined: Wed Jun 23, 2004 12:56 pm
Posts: 126
Location: Prague, Czech Republic


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 5:19 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Last edited by feyd on Wed Aug 24, 2005 7:48 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 6:19 pm 
Offline
Forum Contributor

Joined: Wed Jun 23, 2004 12:56 pm
Posts: 126
Location: Prague, Czech Republic
Actually, the regex without htmlentities seems to be working very well.

i.e.:

Syntax: [ Download ] [ Hide ]
preg_replace('#<.*?(\s+[\w\W]+?(\s*=\s*([\'"]?).*?\\3))*?\>#s','',$test)


Using the above example it will return this string:

testestets>blah

Which is completely correct because the ">" sign is a part of the text, but it gets rid of the ">" sign in the javascript. I am testing everything now and so far haven't found a problem with it.

I'll really have to learn all this regex stuff...

Thanks again!

Tomas


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group