Reputation: 1229
I have large amounts of html similar to
<div>some text</div>
with multiple whitespaces, which I would like to replace with
<div>some text</div>
Is there a way to do this an HTML editor like notepad++/dreamweaver? My problem is isolating only the whitespaces trailing/following text.
Upvotes: 0
Views: 2144
Reputation: 8010
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("#theDiv").text( $("#theDiv").html().replace(/\s/g, " ") );
});
</script>
</head>
<body>
<div id="theDiv">something in here</div>
</body>
</html>
Like this?
Upvotes: 0
Reputation: 69915
If you are looking for using any editor and modify your HTML then you can use replace all feature of notepad++.
The short cut to open replace all dialog box is Ctrl +H. In this dialog box you should enter the string to find and string to replace with and then click on replace.
I hope this makes sense to you. You don't need javascript to do this.
Upvotes: 0
Reputation: 415
As the commenter mentioned, it should be
.
You should be able to do a simple find and replace, replacing space with
. Notepad++ definitely has this feature.
One thing to realize is that nbsp stands for non-breaking space, or put another way, a space that will never allow a line break. If you have a large block of text with all nbsp's, it will all appear on one line and may require horizontal scrolling to read.
Upvotes: 1