Skip to content

Instantly share code, notes, and snippets.

@DanAtkinson
Forked from monkeymonk/remove-accents.js
Created December 2, 2016 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanAtkinson/95b36ea271229234b7292a77b31263b2 to your computer and use it in GitHub Desktop.
Save DanAtkinson/95b36ea271229234b7292a77b31263b2 to your computer and use it in GitHub Desktop.
AngularJS `removeAccents` filter
angular.module('utils.filters', [])
.filter('removeAccents', removeAccents);
function removeAccents() {
return function (source) {
var accent = [
/[\300-\306]/g, /[\340-\346]/g, // A, a
/[\310-\313]/g, /[\350-\353]/g, // E, e
/[\314-\317]/g, /[\354-\357]/g, // I, i
/[\322-\330]/g, /[\362-\370]/g, // O, o
/[\331-\334]/g, /[\371-\374]/g, // U, u
/[\321]/g, /[\361]/g, // N, n
/[\307]/g, /[\347]/g, // C, c
],
noaccent = ['A','a','E','e','I','i','O','o','U','u','N','n','C','c'];
for (var i = 0; i < accent.length; i++){
source = source.replace(accent[i], noaccent[i]);
}
return source;
};
} // removeAccents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment