diff --git a/lib/string.js b/lib/string.js index 985944e..329553e 100644 --- a/lib/string.js +++ b/lib/string.js @@ -432,7 +432,7 @@ string.js - Copyright (C) 2012-2014, JP Richardson stripTags: function() { //from sugar.js var s = this.s, args = arguments.length > 0 ? arguments : ['']; multiArgs(args, function(tag) { - s = s.replace(RegExp('<\/?' + tag + '[^<>]*>', 'gi'), ''); + s = s.replace(RegExp('<(\\/)?(' + (tag || '[^\\s>]+') + ')(\\s+[^<>]*?)?\\s*(\\/)?>', 'gi'), ''); }); return new this.constructor(s); }, diff --git a/test/string.test.js b/test/string.test.js index 254afb1..1474756 100644 --- a/test/string.test.js +++ b/test/string.test.js @@ -640,6 +640,7 @@ it('should strip all of the html tags or tags specified by the parameters', function() { T (S('

just some text

').stripTags().s === 'just some text') T (S('

just some text

').stripTags('p').s === 'just some text') + T (S('just some text').stripTags('i').s === 'just some text') }) })