// *************************************************************************************************
String.prototype.string_reverse = function ()
{ alert('this='+this); // Object = Window!?
return this.split('').reverse().join(''); // CRASHes
};
// usage: str = str.string_reverse() ;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function reverse(s)
{
return s.split('').reverse().join('');
}
// *************************************************************************************************
// *************************************************************************************************
String.prototype.replaceLast = function (what, replacement)
{
return what.string_reverse().replace(new RegExp(what.string_reverse()), replacement.string_reverse()).string_reverse();
};
// usage: str = str.replaceLast('one', 'finish');
The is-used code that burps:
// *************************************************************************************************
String.prototype.strip_phone_format = function ()
{
var phone=this.replace("(","") ; // Error msg: LibraryScripts.js:318 Uncaught TypeError: this.replace is not a function
phone=phone.replace(" ","") ;
phone=phone.replace(")","") ;
phone=phone.replace("-","") ;
return phone ;
} ;// *************************************************************************************************
// *************************************************************************************************
String.prototype.add_phone_format = function ()
{
var just_numbers = this.strip_phone_format() ;
return "("+just_numbers.substr(0,3)+") "+just_numbers.substr(3,3)+"-"+just_numbers.substr(6) ;
} ;
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.