/*
	1. search
	2. split
	3. substr
	4. indexOf
	5. lastIndexOf

*/

// TODO implement accepting regular expressions
String.prototype.search = function(val) {
	
	if(!val || !this.length) {
		return 0;
	}

	var len = this.length,
		index,
		indexFound = -1;

	for(index = 0; index < len; index++) {
		if(this[index] == val) {
			indexFound = index;
			break;
		}
	}

	return indexFound;

};



var str = 'Pranay';

console.log(str.search('r'));


String.prototype.split = function(cond) {
	
	if(!cond) {
		return [this.valueOf()];
	}

	var len = this.length,
		currSub = '',
		index,
		arr = [];

	for(index = 0; index < len; index++) {
		
		if(this[index] == cond) {
			arr.push(currSub);
			currSub = '';
			continue;
		}
		currSub += this[index];
	}

	if(currSub) {
		arr.push(currSub);
	}

	return arr;
};


var str =  'Pranay Dubey';

console.log(str.split(' '));


String.prototype.substr = function(from,to) {
	
	if(!from) {
		return this.valueOf();
	}

	if(to) {
		to = from + (to - 1);
	}

	if(!to) {
		to = this.length - 1;
	}

	var arr = [];

	for(var index = from; index <= to; index++) {
		arr.push(this[index]);
	}

	return arr;
};


var str = 'Pranay Dubey';

console.log(str.substr(4,3));


String.prototype.indexOf = function(val) {

	var index = 0,
		len = this.length,
		indexFound = -1;

	while(index < len) {
		if(this[index] == val) {
			indexFound = index;
			break;
		}
		index++;
	}

	return indexFound;
};


var str = "Pranay Dubey";

console.log(str.indexOf("a"));

String.prototype.lastIndexOf = function(val) {

	var len = this.length,
		indexFound = -1;

	while(len--) {
		if(this[len] == val) {
			indexFound = len;
			break;
		}
	}

	return indexFound;
};

var str = "Pranay Dubey";

console.log(str.lastIndexOf("y"));
@@ -55,16 +55,48 @@
 tIndexOf
+%0A%096. anchor%0A%097. concat%0A%098. match
 %0A%0A*/%0A%0A//
@@ -1769,12 +1769,854 @@
 dexOf(%22y%22));
+%0A%0AString.prototype.anchor = function(name) %7B%0A%09var value = this.valueOf() %7C%7C '',%0A%09%09elemName = name %7C%7C undefined;%0A%0A%09return '%3Ca name=%22' + elemName + '%22%3E' + value + '%3C/a%3E';%0A%7D;%0A%0Avar str = %22Pranay Dubey%22;%0A%0Aconsole.log(str.anchor('something'));%0A%0AString.prototype.concat = function(str) %7B%0A%09str = str %7C%7C '';%0A%09return this.valueOf() + str;%0A%7D;%0A%0Avar str = %22Pranay%22;%0A%0Aconsole.log(str.concat(' Dubey'));%0A%0A%0AString.prototype.match = function(val) %7B%0A%09%0A%09if(typeof val == 'object' && val.constructor == RegExp) %7B%0A%09%09return val.exec(this.valueOf());%0A%09%7D%0A%0A%09var arr = null,%0A%09%09index = 0,%0A%09%09len = this.length;%0A%0A%09while(index %3C len) %7B%0A%09%09if(this%5Bindex%5D == val) %7B%0A%09%09%09arr = %5Bval%5D;%0A%09%09%09arr%5B%22index%22%5D = index;%0A%09%09%09arr%5B%22input%22%5D = this.valueOf();%0A%09%09%09break;%0A %09%09%7D%0A %09%09index++;%0A%09%7D %0A%0A%09return arr;%0A%7D;%0A%0Avar str = %22Pranay Dubey%22;%0A%0Aconsole.log(str.match('a'));%0A%0Aconsole.log(str.match(/a/));

Add string methods for anchor,concat and match