473,372 Members | 1,099 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,372 software developers and data experts.

delete new line, tab in html code

I take html code and I want to get it without new line, tab...;

But, It doesn't work.

My code :

<HTML>
<SCRIPT language=javascript>
function transform() {
var html= document.getElementById("corps").innerHTML;
alert(html.replace("[\f\n\r\t\v]*",""))
}
</SCRIPT>
<BODY onload=transform()>
<DIV id="corps">
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</P>
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</P>
<P>
<TABLE>
<TR><TD>
<TABLE>
ppppppppppppppppppppppp
</TABLE>
<P>aaaaaaaaaaaaaaaaaaaaa</P>
</TD></TR>
</TABLE>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaa</P>
</DIV>
</BODY>
</HTML>

May 25 '07 #1
1 4404
On May 25, 1:56 pm, louv...@gmail.com wrote:
I take html code and I want to get it without new line, tab...;

But, It doesn't work.

My code :

<HTML>
<SCRIPT language=javascript>
function transform() {
var html= document.getElementById("corps").innerHTML;
alert(html.replace("[\f\n\r\t\v]*",""))}

</SCRIPT>
<BODY onload=transform()>
<DIV id="corps">
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</P>
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</P>
<P>
<TABLE>
<TR><TD>
<TABLE>
ppppppppppppppppppppppp
</TABLE>
<P>aaaaaaaaaaaaaaaaaaaaa</P>
</TD></TR>
</TABLE>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<P>aaaaaaaaaaaaaaaaaaaaaaaaaaaa</P>
</DIV>
</BODY>
</HTML>
You have troubles determining your regular expression. First thing,
the first argument you don't surround with double quotes but with
slashes, and the second thing, you have to add 'g' after the last
slash, which means 'global' (or whatever, anyway it means that you
want to find ALL occurrences and replace them). So, the conclusion:

alert(html.replace(/[\f\n\r\t\v]*/g, ""));

May 25 '07 #2

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

Similar topics

1
by: Franco Fellico' | last post by:
Hi. Suppose to have read and displayed (using PHP) a group of row of a DB table on a dinamyc table on a HTML/PHP page. The number of row displayed could be from 1 to n. Each row contains...
1
by: Sandy | last post by:
I have a repeater which shows Group names. (Skip this part if you want rather irrelevant) The groups are ordered and formatted: Parent ---Child ------Grand Child (okay start reading again...
3
by: silver360 | last post by:
Hello, I'm trying to create a basic Heap manager and i have some question about new/delete overloading. The following code give me this output : >> $./heap >> registered : 0x804d098 >>...
9
by: Juergen Huber | last post by:
hello, i am a dummy user in python and new in this programming language and so there will be questions, that´s for you no problem! i never have before programmed in any language! sorry for this!...
22
by: Cylix | last post by:
I have a 4row x 1col table, I would like to drop all the content of row three. Since Mac IE5.2 does not suppport deleteRow method, I have also try to set the innerHTML=''; but it does not work. ...
5
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
12
by: yufufi | last post by:
Hello, How does delete know how much memory to deallocate from the given pointer? AFAIK this informations is put there by new. new puts the size of the allocated memory before the just before...
3
by: myth0s | last post by:
Hello! In VB.NET I have a GridView that shows a list of dates and beside each date there's a delete button. For a reason I don't know, the delete event seems to be fired twice, but I have...
4
nomad
by: nomad | last post by:
Hello Everyone: I'm working on a project for a client in which they want to add and delete events for a selected day on a calendar. I have built the calendar and added the events, but I'm having...
4
by: jeddiki | last post by:
Hi, I have written a script that is listing articles from my article table and displaying the titles ten on each page. As I need to calculate and print other stuff in between the extracting ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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 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.