I want too know how I can parse for <script and </script> and replace them with nothing. For some reason my preg_replace isn't working the way I planned it..
I don't have the code of the function since I deleted it and didn't back it up.
So can someone help me out?
Thanks, Ajm113.
8 2514
Heya, AJM.
My suggestion, rather than to allow all tags except <script> is to disallow all tags except for certain ones that you have decided are benign. PHP: strip_tags - Manual
I think you mist read my topic, I already have that going, Its just it's not removing the code between the tags. str_replace is the function I want too work with.
it could be that because of the added escape characters your RegEx doesn't work. you can check that by dumping the string to evaluate just before the RegEx.
regards
@Ajm113
AJM,
In that case I think you need to tackle the problem in 2 steps:
1. Using str_pos() and substr() you can define a variable that is basically the contents of the '<script>... ...</script>' tags.
2. Using that new variable and the str_replace() function you can replace the new string with ''
Hope that helps.
nathj
@Ajm113
Unfortunately, Pb is not psychic, although he sometimes likes to believe it; without seeing the current code you are using, how can we point out why it isn't doing as you'd like?
Sorry, substr, isn't going to work in this case, I actually forgot that my code returns line by line in a loop and prints it.
So what would be a good way on telling it not too show text until it see's the </script> tag?
Sorry, wasn't thinking, lol. I am making a mobile viewer and I am trying too cut off CSS and Javascript code.
Ah, Ok. Now I see what you're saying.
The first idea that comes to mind would be to do a regular expression along the lines of - !<script.*?>.+?</script>!
But it sounds like the regexp route wasn't working for you....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Fazer |
last post by:
Hello,
I was wondering what would be the easiest way to strip away HTML tags from a string?
Or how would I remove everything between < and > also the < , > as well using regex?
Thanks for...
|
by: lievemario |
last post by:
I have made a perl script witch gets information out of a database,
transfers it into an xml-file file and than I parse this to a html document
using xsl.
The problem is dat the html doc needs a...
|
by: Julie Miles |
last post by:
I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous file
containing a massive amount of css formatting. I'd like...
|
by: |
last post by:
I have a script...
-----
<SCRIPT language="JavaScript" type="text/javascript">
<!--
function makeArray() {
for (i = 0; i<makeArray.arguments.length; i++)
this = makeArray.arguments;
}
...
|
by: Jakej |
last post by:
I've been using a javascript in an html file for a banner slider, and
it works as desired. But I'd like to use it on more than one page and
it would be great if I could transfer the code to a .js...
|
by: localhost |
last post by:
I have these in all of my pages:
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript...
|
by: Danny |
last post by:
Hallo, all
I have used this function.
$string = strip_tags($p1,'<i><b><u><br><p><font>');
The problem is that the title will be printed as well, but i dont allow the
title tag.
How to i...
|
by: Steve |
last post by:
Hi,
I'm a complete PHP n00b slowly finding my way around
I'm using the following function that I found on php.net to strip
out html and return only the text. It works well except for when
you...
|
by: george |
last post by:
hello,
which is the best way to strip jscript/vbscript from user input? Is
there any module I could reuse?
thanks in advance
george
P.S. the solution must allow users to enter html code.
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |