Reputation: 1764
In python there is a method to replace a certain character(s) at the edges of a string, such as:
>>> " , hello,".strip(", ")
'hello'
Is there a method to do this in javascript, or does it need to be done with a regular expression? For example:
console.log("'" + " , hello,".replace(/^\W+|\W+$/g, "") + "'");
Upvotes: 0
Views: 43
Reputation: 21354
No, there is no such method. There is only .trim(), which only trims white space.
Upvotes: 1