Monthly Archives: August 2014

Striping apostrophe from beginning and end of string using JavaScript

For me the JavaScript only provides most primitive set of capabilities that are required by most developers. That is one reason what made jQuery a popular framework. 

To do even simple thing like trimming a sting with a know character is not possible unless you write your own routine. What I have demonstrated here is addition of a function to String type to remove single quotes (an apostrophe) from beginning and end of a string.

String.prototype.unquoted = function (){return this.replace (/(^’)|(‘$)/g, ”)}

var str=”‘hello'”