473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Remove javascript content from HTML page using Perl

I am creating a search engine that will scan pages on my Web site. I do not
want any false-positive hits, being defined as any match that does not appear
on the page using a Web browser.

I am using a string of regexp statements to do this. The first one removes
anything before the <body> tag since it contains, among other things, general
keywords and function definitions. The goal of the next one is to remove
<script including attributes>all code</script>. The third regexp strips any
HTML tag, <anything>. I have a Javascript function called presentphoto(...)
that I don't want to be found when using the search function to find 'photo'.
The first and third regexp work fine. I thought the second regexp,
/<script[^>]*>[^<]*<\/script>//gs would do what I wanted. It does handle the
photo problem but something else is wrong as searches for write find
document.write(...) between the <script>document.write(...)</script> tag.

Can anyone help with a better expression to remove everything between <script
type="text/javascript">...</script>?

Thanks.
Jul 19 '05 #1
1 10528
Mark wrote:

/<script[^>]*>[^<]*<\/script>//gs would do what I wanted. It does handle the

s%<script.*?>.*?</script>%%gsi;

If that does not help, re-post your question to comp.lang.perl.misc
instead of comp.lang.perl .
-Joe
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.