Wednesday, March 31, 2010

strLeft in javascript

String.prototype.strLeft=function(seperator)    {
    //stringValue
    var pos=this.indexOf(seperator);
    var result=this.substring(0,pos)
    return result;
}

alert("xkrky".strLeft('k')); // will alert 'x'


function strLeft(stringValue,seperator)    {
    var pos=stringValue.indexOf(seperator);
    var result=stringValue.substring(0,pos)
    return result;
}

alert(strLeft("xkrky",'k')); // will alert 'x'

2 comments:

  1. It might give us macro support, rapid testing facilities for programmers (just load your Plug-in and access it with the Script Shell) and maybe a lot more things I can currently not think of.psd to email

    ReplyDelete
  2. 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.

    ReplyDelete