Wednesday, March 31, 2010

strLeftBack in javascript

String.prototype.strLeftBack=function(seperator)    {
    var pos=this.lastIndexOf(seperator);
    var result=this.substring(0,pos)
    return result;

alert("xkrky".strLeftBack('k')); //will alert 'xkr'

function strLeftBack(stringValue,seperator)    {
    var pos=stringValue.lastIndexOf(seperator);
    var result=stringValue.substring(0,pos)
    return result;

alert(strLeftBack("xkrky",'k')); //will alert 'xkr'

1 comment:

  1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head.
    I am highly impressed with your blog. It is very nicely explained.
    Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.