Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
58
rated 0 times [  62] [ 4]  / answers: 1 / hits: 191948  / 13 Years ago, wed, july 13, 2011, 12:00:00

I have two variables:



site1 = www.somesite.com;  
site2 = www.somesite.com/;


I want to do something like this



function someFunction(site)
{
// If the var has a trailing slash (like site2),
// remove it and return the site without the trailing slash
return no_trailing_slash_url;
}


How do I do this?


More From » string

 Answers
78

Try this:



function someFunction(site)     
{
return site.replace(//$/, );
}

[#91203] Tuesday, July 12, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
whitney

Total Points: 642
Total Questions: 110
Total Answers: 98

Location: Solomon Islands
Member since Mon, Jun 20, 2022
2 Years ago
;