Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-10-2003, 03:12 PM   #1
Registered User
LeahSmart's Avatar
Join Date: May 2003
Location: Devon, UK
Posts: 100
Send a message via MSN to LeahSmart
Default Removing space's from the start and end of a string

Hi Reader.

I have a program where a user enters some text. Some times the user adds one or more spaces at the front and/or back of the text they have entered, for example:

(" I am the space master! ")

Is there anyway to remove these spaces but still leave the other spaces there. So the above would come the below:

("I am the space master!")

I have seen there are already some posts on this topic but they all remove all the spaces in the string. I just want to remove the ones at the beginning and end.


LeahSmart is offline   Reply With Quote
Old 06-10-2003, 03:35 PM   #2
six eyes
senocular's Avatar
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular

look here
you might find something that helps
senocular is offline   Reply With Quote
Old 06-10-2003, 05:07 PM   #3
New Member
Join Date: Jan 2001
Posts: 245

Try this-

str = " abcd efg ";
var newstr = "";
var k = str.length-1;

function test()
if(str.substr(0,1) == " ")
newstr = str.substr(1, k);

if(str.substr(k,1) == " ")
newstr = newstr.substr(0, newstr.length-1);

mgb is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 11:24 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.