Javascript code to get a string sliced till last occurrence of a character function
//javascript
getStringTillLastCharcter(str,chr)
{
var flag=0;
var lastpos;
//alert(str.length);
for(i=0;i < str.length; i++ ) {
if(str.charAt(i)==chr)
{
lastpos=i+1;
}
}
//alert(lastpos);
return str.slice(0,lastpos);
}
Here is a code to get the string till the last occurance of a charcter.....
//javascript
getStringTillLastCharcter(str,chr)
{
var flag=0;
var lastpos;
//alert(str.length);
for(i=0;i
if(str.charAt(i)==chr)
{
lastpos=i+1;
}
}
//alert(lastpos);
return str.slice(0,lastpos);
}
Here is a code to get the string till the last occurance of a charcter.....
No comments:
Post a Comment