String Trim Function

They have: 39 posts

Joined: Jun 2000

Is there any Ltrim or RTrim string functions in Javascript, I want remove space at the end of my string?

Thanks

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

There are no built-in trim functions. However, I do have some at my site (including lTrim & rTrim) that can be used to strip blanks, return individual words in a phrase, etc.

Vinny

------------------
my site:GrassBlade: cut&paste javascript
moderator at:The Javascript Place
Javascript City

Where the world once stood
the blades of grass cut me still

They have: 231 posts

Joined: Feb 2000

Here is a quick trim script using regular expressions. STR equals the string to trim.

code:

function trimAll(STR) {
   return STR.replace(/^\s|\s$/g,"");
   }[/code]

[This message has been edited by Lloyd Hassell (edited 19 June 2000).] 

:: Lloyd Hassell :: http://www14.brinkster.com/lloydh ::

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.