A couple of times I have needed to slice the right part of a string based on a delimiting character. I performed a couple of searches looking for a function to place in my toolbox, but came up empty. Below is my creation.
function rightstr(s,c)
{
L = s.lastIndexOf(c);
L=L+1;
return s.slice(L);
}
A couple of examples of how this function can be used:
rightstr('images/ico_note.gif','\')
This will return ico_note.gif
or for grabbing the value of a querystring value at the end of a url:
rightstr('http://tvplanner.comcast.net/?initView=schedule','=')
This will return schedule
Thursday, November 15, 2007
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment