SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript and replace?

    I'm trying to figure out how to replace empty spaces using replace...

    I have tryid this but with no luck...
    Code JavaScript:
    var seo_sc = new Array (
    			  ' ','-','/','\\',',','#',':',';','\'','"','[',']','%20','{','}',
    			  ')','(','|','`','~','!','@','%','$','^','&','*','=','?','+');
    var file = file.replace(seo_sc,'-',file);

    Can this be done?

  2. #2
    Forums Designer
    Join Date
    Jun 2004
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    Code:
    file = file.replace(/\s/g, '-');
    or some other regular expression


Bookmarks

Posting Permissions

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