SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [REGEX] Replace a url ask for advice.

    HI.

    I've to replace a string like this

    in

    I managed this simple very simple
    regex

    PHP Code:
    var myUrlimgTarget.src.toString();
    newUrl myUrl.replace(/thumbs/g,"uploaded"); 
    Is there a way to improve it ?

    Bye.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No need for regex. Also no need to do "toString" - it's a string already.

    Code:
    var newUrl = imgTarget.src.replace('thumbs', 'uploaded');

  3. #3
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

    Bye.


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
  •