This is my angularjs filter :
app.filter('cleanit', function() {
return function (input) {
input = input.replace(new RegExp('é'),'é');
input = input.replace(new RegExp('É'),'É');
input = input.replace(new RegExp('Ô'),'Ô');
input = input.replace(new RegExp('''), '\'');
return input;
}
});
I use it for replace bad accents in feeds parsed with Google Feed API. It's works good but it's only works once per item, the replacement no longer takes place then, after the first success. what's wrong ?
gmodifier to your RegExps to make it global. You can also do this using/regex/gsyntax instead of using thenew RegExp()constructor because your regexes are statically defined.