Node.js examples for String:Strip
Return a new string with the value stripped from the right of the string
/**/* w ww. j a v a 2 s . c o m*/ * Return a new string with the value stripped from the right of the string * @version 1.1.1 * @date July 22, 2010 * @package jquery-sparkle {@link http://www.balupton/projects/jquery-sparkle} * @author Benjamin "balupton" Lupton {@link http://www.balupton.com} * @copyright (c) 2009-2010 Benjamin Arthur Lupton {@link http://www.balupton.com} * @license GNU Affero General Public License version 3 {@link http://www.gnu.org/licenses/agpl-3.0.html} */ String.prototype.stripRight = String.prototype.stripRight || function(value,regex){ // Strip a value from the right, with optional regex support (defaults to false) value = String(value); var str = this; if ( value.length ) { if ( !(regex||false) ) { // We must escape value as we do not want regex support value = value.replace(/([\[\]\(\)\^\$\.\?\|\/\\])/g, '\\$1'); } str = str.replace(eval('/'+value+'+$/g'), ''); } return String(str); }