problem replacing spaces in a string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Philo Hippo

    #1

    problem replacing spaces in a string

    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 SearchForDomain s(winName, SearchWhat)
    {
    var re = /\s*(\w*)\s*/;
    SearchWhat=Sear chWhat.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

    philippeoget at yahoo dot com

    Programming Excel: <a
    href="http://uk.geocities.co m/philippeoget/xl/InternetLinkOrg aniser.zip"
    target="_blank" >The Excel A2Z Project: </a>



  • Michael Winter

    #2
    Re: problem replacing spaces in a string

    On Mon, 11 Oct 2004 04:48:23 +0100, Philo Hippo <philippeoget@h otmail.com>
    wrote:
    [color=blue]
    > I need to be able to remove spaces from the beginning or the end of a
    > string.[/color]

    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.

    Comment

    • Philo Hippo

      #3
      Re: problem replacing spaces in a string

      Thank you Mike


      Phil

      philippeoget at yahoo dot com

      Programming Excel: <a
      href="http://uk.geocities.co m/philippeoget/xl/InternetLinkOrg aniser.zip"
      target="_blank" >The Excel A2Z Project: </a>


      "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
      news:opsfo265fx x13kvk@atlantis ...[color=blue]
      > On Mon, 11 Oct 2004 04:48:23 +0100, Philo Hippo <philippeoget@h otmail.com>
      > wrote:
      >[color=green]
      > > I need to be able to remove spaces from the beginning or the end of a
      > > string.[/color]
      >
      > 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.[/color]



      Comment

      Working...