CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Stop linebreak in Html ban

 



fds
Novice

Jan 28, 2011, 5:42 AM

Post #1 of 3 (481 views)
Stop linebreak in Html ban Can't Post

Hi, I use this in a script to ban HTML tags.

Code
$line =~ s/<.+?>(.+?<.+?>)*\n*//g;

It works fine, unless I do something like this:

Code
<a href=""> 
Link name </a>

or

a href="">
Link name
</a>

Then the name of the link appears etc.

Is there a simple way to stop multiple linebreaks inside HTML tags (basically to cover all possibilities).

Trust someone can help out on this - thanks.
----------------------------------------------
fdsaadsfdsaf

(This post was edited by Ted on Jan 28, 2011, 5:42 AM)


BillKSmith
Veteran

Jan 28, 2011, 6:37 AM

Post #2 of 3 (474 views)
Re: [Ted] Stop linebreak in Html ban [In reply to] Can't Post

It is seldom a good idea to parse html with a regular expression. You almost certainly will continue to encounter possibilites which you had not thought of. Use a module from CPAN.
Good Luck,
Bill


fds
Novice

Jan 28, 2011, 7:40 AM

Post #3 of 3 (470 views)
Re: [BillKSmith] Stop linebreak in Html ban [In reply to] Can't Post

OK, thanks Bill.
----------------------------------------------
fdsaadsfdsaf

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives