Refactor Code

  • Gravatar
    Extract File Name from URL Using JavaScript

    by azamsharp on 7/18/2008 1:21:19 PM
  • I found this nifty code online that extracts file name from the url using JavaScript code. This can be performed better by using Regular Expressions (any takes?)
  • function getFileNameFromUrl(url)
    {
    wholeurl = url;
    x = wholeurl.length;
    while((wholeurl.substring(x,x-1)) != "/"){ x--; }
    return wholeurl.substring(wholeurl.length,x);
    }
  • Refactor it!
  • Gravatar
    will that possibly work man
    by gojecks on 9/4/2008 9:13:54 AM
  • Gravatar
    Hi GoJecks, Are you facing any problems with the above code?
    by azamsharp on 9/4/2008 9:15:08 AM
Please log in to refactor the code! Login