Wednesday, March 31, 2010

strRight in javascript

String.prototype.strRight=function(seperator)    {
    //stringValue
    var pos=this.(seperator);
    var result=this.substring(pos+1,this.length)
    return result;
}

alert("xkr".strRight('k'));  // will alert 'r'

function strRightBack(stringValue,seperator)    {
    var pos=stringValue.indexOflastIndexOf(seperator);
    var result=stringValue.substring(pos+1,stringValue.length)
    return result;
}

alert(strRightBack("xkr",'k')); // will alert 'r'

3 comments:

  1. For strRightBack it should be lastIndexOf instead of indexOf, shouldn't it?

    ReplyDelete
    Replies

    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

      Delete
  2. Yes thats true. Thank you for pointing it out. I changed it

    ReplyDelete