View Full Version : String Trim
asuni449
Feb 24th 2009, 8:39 pm
Hi all,
I am new to Javascript.
How to trim a sting in javascript.
Ex:
I had a srting as 'a df grt'
I want the trim result as 'adfgrt'.
Can anyone tell me how to do this.
Thanks
:)
shubhamjain1
Mar 9th 2009, 3:32 am
Remove spaces and do a bubble sort or any other sorting techniques..!!
bprashanth.gi
Mar 9th 2009, 11:09 am
Not very professional, but works though :)
<script type="text/javascript">
var name;
var strName='';
name="H e e";
for(i=0;i<name.length;i++)
{
var e=name.substring(i,i+1);
if (e==' ')
{}
else
strName+=e;
alert(e);
}
document.write(strName);
document.write("<br />");
</script>
xlcho
Mar 10th 2009, 2:15 am
var string = "a df grt";
while(string.indexOf(" ") != -1)
string = string.replace(" ", "");
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.