www.webdeveloper.com
Results 1 to 3 of 3

Thread: Transform a string

  1. #1
    Join Date
    Jan 2010
    Location
    Belgium
    Posts
    319

    Transform a string

    Hello,

    Can any of you guys help me out with the following string transformation pls?

    /hi/guys/id/from/page

    ... has to become ...

    hi.guys.id.from.page

    I already got:

    Code:
    var str = '/hi/there/guys';
    
    log( str.slice(1).replace('/', '.') );
    // returns 'hi.there/guys'

    Thanks for the help!

    Christophe

  2. #2
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,644
    Code:
    var str = '/hi/there/guys';
    alert( str.replace(/\//g,'.'));
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Jan 2010
    Location
    Belgium
    Posts
    319
    thanks!!!

Thread Information

Users Browsing this Thread

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

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