problem replacing spaces in a string

Discussion in 'Javascript' started by Philo Hippo, Oct 11, 2004.

  1. Philo Hippo

    Philo Hippo Guest

    Hi,

    I need to be able to remove spaces from the beginning or the end of a
    string.

    This is my very 1st attempt at doing that in JS and here is what i got:

    function SearchForDomains(winName, SearchWhat)
    {
    var re = /\s*(\w*)\s*/;
    SearchWhat=SearchWhat.replace(re, "$1");
    ....

    that gets rid of the spaces at the front of the string, but not at the end
    of it.

    Can you help me please?


    --

    Hope that helps,

    Phil
    http://uk.geocities.com/philippeoget
    philippeoget at yahoo dot com

    Programming Excel: <a
    href="http://uk.geocities.com/philippeoget/xl/InternetLinkOrganiser.zip"
    target="_blank">The Excel A2Z Project: </a>
    http://uk.geocities.com/philippeoget/a2z/
    Philo Hippo, Oct 11, 2004
    #1
    1. Advertising

  2. On Mon, 11 Oct 2004 04:48:23 +0100, Philo Hippo <>
    wrote:

    > I need to be able to remove spaces from the beginning or the end of a
    > string.


    A solution has already been provided in the FAQ
    (<URL:http://jibbering.com/faq/>).

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
    Michael Winter, Oct 11, 2004
    #2
    1. Advertising

  3. Philo Hippo

    Philo Hippo Guest

    Thank you Mike


    Phil
    http://uk.geocities.com/philippeoget
    philippeoget at yahoo dot com

    Programming Excel: <a
    href="http://uk.geocities.com/philippeoget/xl/InternetLinkOrganiser.zip"
    target="_blank">The Excel A2Z Project: </a>
    http://uk.geocities.com/philippeoget/a2z/

    "Michael Winter" <> wrote in message
    news:eek:psfo265fxx13kvk@atlantis...
    > On Mon, 11 Oct 2004 04:48:23 +0100, Philo Hippo <>
    > wrote:
    >
    > > I need to be able to remove spaces from the beginning or the end of a
    > > string.

    >
    > A solution has already been provided in the FAQ
    > (<URL:http://jibbering.com/faq/>).
    >
    > [snip]
    >
    > Mike
    >
    > --
    > Michael Winter
    > Replace ".invalid" with ".uk" to reply by e-mail.
    Philo Hippo, Oct 12, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John B. Matthews
    Replies:
    4
    Views:
    665
    John B. Matthews
    Sep 12, 2008
  2. Roedy Green
    Replies:
    3
    Views:
    620
  3. Rob Meade

    Replacing - and not Replacing...

    Rob Meade, Apr 5, 2005, in forum: ASP General
    Replies:
    5
    Views:
    273
    Chris Hohmann
    Apr 11, 2005
  4. Vapor ..

    replacing spaces

    Vapor .., Nov 19, 2007, in forum: Ruby
    Replies:
    2
    Views:
    84
    Vapor ..
    Nov 19, 2007
  5. George George

    replacing verticle white spaces?

    George George, Jul 17, 2009, in forum: Ruby
    Replies:
    4
    Views:
    144
Loading...

Share This Page