473,473 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4406
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 ...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.