1 // Removes a substring from a string
2 function webdeveloper_removeSubstring(string
, substring
)
4 // If the strings are not empty
5 if(string
&& substring
)
7 var substringStart
= string
.indexOf(substring
);
9 // If the substring is found in the string
10 if(substring
&& substringStart
!= -1)
12 return string
.substring(0, substringStart
) + string
.substring(substringStart
+ substring
.length
, string
.length
);
21 // Tests if a string ends with the given string
22 String
.prototype.endsWith = function(endsWithString
)
24 return (this.substr(this.length
- endsWithString
.length
) == endsWithString
);
27 // Trims leading and trailing spaces from a string
28 String
.prototype.trim = function()
30 return this.replace(new RegExp("^\\s+|\\s+$", "gi"), "");