I'm trying to abbreviate a long list of .replace() sterilisation I'm applying to a string variable by writing my own jquery method.
jQuery.fn.ACsterilise = function() {
var text = this.text;
var sterilisedText = "foo test bar";
sterilisedText = text.toUpperCase().replace(/\'/g,"").replace(/\,/g,"").replace(/\-/g," ");
return sterilisedText;
};
and then calling it
var stringToSterilise = "testi'ng fo'o st'ring bar"
var sterilisedString = stringToSterilise.ACsterilise();
But with no luck. I feel jquery is a bad choice as I'm working with a string not the DOM. Am new to javascript.