www.webdeveloper.com
Results 1 to 3 of 3

Thread: regex replace

Hybrid View

  1. #1
    Join Date
    Jul 2004
    Location
    India
    Posts
    34

    regex replace

    var string="removespace : dont remove spaces";

    need a regex which replaces all spaces before and after colon ':' .

    above variable must be returned as

    "removespacedont remove spaces"
    johns221b

  2. #2
    Join Date
    Oct 2008
    Location
    U.S.
    Posts
    726
    Code:
    var string="removespace : dont remove spaces";
    var str = string.replace(/\s+:\s+/g, ''); //insert colon : in the '' if you want the colon left in
    alert(str);
    Last edited by astupidname; 11-27-2009 at 02:18 AM.

  3. #3
    Join Date
    Jul 2004
    Location
    India
    Posts
    34
    thanks
    johns221b

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles