# Replace function

**URL:** <https://forum.kirupa.com/t/replace-function/148982>\
**Category:** Uncategorized\
**Created:** [May 25, 2005, 5:53am UTC](https://forum.kirupa.com/t/replace-function/148982 "2005-05-25T05:53:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vintage](https://avatars.discourse-cdn.com/v4/letter/v/e68b1a/32.png) [@vintage](https://forum.kirupa.com/u/vintage)\
**Post date:** [May 25, 2005, 5:53am UTC](https://forum.kirupa.com/t/replace-function/148982/1 "2005-05-25T05:53:05Z")

</div>

hello people.  
I’ve got this piece of code from someone, and it works fine, but i want to replace more characters.

```auto
String.prototype.replace = function(pattern, replacement, limit) {
			if (!limit) {
				return this.split(pattern).join(replacement);
			} else {
				var arr = this.split(pattern, limit+1);
				var str = this.substr(arr.join(pattern).length);
				return arr.join(replacement)+str;
			}
		};
		
		
		filtertitel = titel.replace("& amp", "&");

```

Anyone knows how i can do that ?  
Thanks
