Wednesday, March 31, 2010

strLeft in javascript

String.prototype.strLeft=function(seperator)    {
    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'

1 comment:

  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