Forked from fabiofdsantos/angularJS_removeAccents.js
Last active
July 12, 2025 21:44
-
-
Save marcelo-ribeiro/abd651b889e4a20e0bab558a05d38d77 to your computer and use it in GitHub Desktop.
Revisions
-
marcelo-ribeiro revised this gist
Aug 18, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // Example: https://codepen.io/marcelo-ribeiro/pen/PomqOvE const accentsMap = new Map([ ["-", "\\s|\\.|_"], ["a", "á|à|ã|â|ä"], ["e", "é|è|ê|ë"], ["i", "í|ì|î|ï"], -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ export const slugify = text => text .replace(/\s|_|\(|\)/g, "-") .normalize("NFD").replace(/\p{Diacritic}/gu, "") .toLowerCase() -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 2 changed files with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ export const removeAccents = text => text .replace(/\s|_|\(|\)/g, "-") .normalize("NFD").replace(/\p{Diacritic}/gu, "") .toLowerCase() This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1 @@ export const removeAccents = text => text.normalize("NFD").replace(/\p{Diacritic}/gu, "") -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,3 @@ export const removeAccents = text => text .replace(/\s|_|\(|\)/g, "-") .normalize("NFD").replace(/\p{Diacritic}/gu, "") -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 2 changed files with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ export const slugify = text => text .replace(/\\s|_|(|)/g, "-") .normalize("NFD").replace(/\p{Diacritic}/gu, "") This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ export const removeAccents = text => text.normalize("NFD").replace(/\p{Diacritic}/gu, "") -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Example: https://codepen.io/marcelo-ribeiro/pen/OJmVOyW const accentsMap = new Map([ ["A", "Á|À|Ã|Â|Ä"], -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 2 changed files with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ // Example: https://codepen.io/marcelo-ribeiro/pen/PomqOvE const accentsMap = new Map([ ["A", "Á|À|Ã|Â|Ä"], ["a", "á|à|ã|â|ä"], ["E", "É|È|Ê|Ë"], ["e", "é|è|ê|ë"], @@ -11,7 +13,7 @@ const accentsMap = new Map([ ["u", "ú|ù|û|ü"], ["C", "Ç"], ["c", "ç"], ["N", "Ñ"], ["n", "ñ"] ]); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // Example: https://codepen.io/marcelo-ribeiro/pen/PomqOvE const accentsMap = new Map([ ["-", "\\s|_"], ["a", "á|à|ã|â|ä"], -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 2 changed files with 23 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,20 @@ const accentsMap = new Map([ ["A", "Á|À|ã|Ã|Â|Ä"], ["a", "á|à|ã|â|ä"], ["E", "É|È|Ê|Ë"], ["e", "é|è|ê|ë"], ["I", "Í|Ì|Î|Ï"], ["i", "í|ì|î|ï"], ["O", "Ó|Ò|Ô|Õ|Ö"], ["o", "ó|ò|ô|õ|ö"], ["U", "Ú|Ù|Û|Ü"], ["u", "ú|ù|û|ü"], ["C", "Ç"], ["c", "ç"], ["N", "Ñ"] ["n", "ñ"] ]); const reducer = (acc, [key]) => acc.replace(new RegExp(accentsMap.get(key), "g"), key); export const removeAccents = (text) => [...accentsMap].reduce(reducer, text); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ const accentsMap = new Map([ ["-", "\\s|_"], ["a", "á|à|ã|â|ä"], ["e", "é|è|ê|ë"], ["i", "í|ì|î|ï"], ["o", "ó|ò|ô|õ|ö"], ["u", "ú|ù|û|ü"], ["c", "ç"], ["n", "ñ"] ]); const reducer = (acc, [key]) => acc.replace(new RegExp(accentsMap.get(key), "gi"), key); export const slugify = (text) => [...accentsMap].reduce(reducer, text.toLowerCase()); -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,4 +11,4 @@ const accentsMap = new Map([ const reducer = (acc, [key]) => acc.replace(new RegExp(accentsMap.get(key), "gi"), key); export const slugify = (text) => [...accentsMap].reduce(reducer, text.toLowerCase()); -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,6 @@ const accentsMap = new Map([ ["n", "ñ"] ]); const reducer = (acc, [key]) => acc.replace(new RegExp(accentsMap.get(key), "gi"), key); export const slugify = (text) => [...accentsMap].reduce(reducer, text.toLowerCase()); -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,8 +9,6 @@ const accentsMap = new Map([ ["n", "ñ"] ]); const reducer = (acc, key) => acc.replace(new RegExp(accentsMap.get(key), "gi"), key); export const slugify = (text) => [...accentsMap.keys()].reduce(reducer, text.toLowerCase()); -
marcelo-ribeiro revised this gist
Jul 1, 2021 . 1 changed file with 14 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,16 @@ const accentsMap = new Map([ ["-", "\\s|_"], ["a", "á|à|ã|â|ä"], ["e", "é|è|ê|ë"], ["i", "í|ì|î|ï"], ["o", "ó|ò|ô|õ|ö"], ["u", "ú|ù|û|ü"], ["c", "ç"], ["n", "ñ"] ]); const reducer = (acc, key) => acc.replace(new RegExp(accentsMap.get(key), "gi"), key); export const slugify = (text) => [...accentsMap.keys()].reduce(reducer, text.toLowerCase()); -
marcelo-ribeiro revised this gist
Apr 9, 2021 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,18 @@ const slugify = str => { const map = { '-' : ' ', '-' : '_', 'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä', 'e' : 'é|è|ê|ë|É|È|Ê|Ë', 'i' : 'í|ì|î|ï|Í|Ì|Î|Ï', 'o' : 'ó|ò|ô|õ|ö|Ó|Ò|Ô|Õ|Ö', 'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü', 'c' : 'ç|Ç', 'n' : 'ñ|Ñ' }; for (var pattern in map) { str = str.replace(new RegExp(map[pattern], 'g'), pattern); } return str; -
marcelo-ribeiro revised this gist
Apr 9, 2021 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,19 @@ const slugify = str => { const map = { '-' : ' ', '-' : '_', 'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä', 'e' : 'é|è|ê|ë|É|È|Ê|Ë', 'i' : 'í|ì|î|ï|Í|Ì|Î|Ï', 'o' : 'ó|ò|ô|õ|ö|Ó|Ò|Ô|Õ|Ö', 'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü', 'c' : 'ç|Ç', 'n' : 'ñ|Ñ' }; for (var pattern in map) { str = str.replace(new RegExp(map[pattern], 'g'), pattern); } return str; } -
marcelo-ribeiro revised this gist
Apr 9, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ const slugify = str => { const map = { '-' : ' ', '-' : '_', 'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä', -
marcelo-ribeiro revised this gist
Apr 9, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function slugify (str) { for (var pattern in map) { str = str.replace(new RegExp(map[pattern], 'g'), pattern); } return str; } -
marcelo-ribeiro revised this gist
Mar 11, 2021 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,10 @@ function slugify (str) { var map = { '-' : ' ', '-' : '_', 'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä', 'e' : 'é|è|ê|ë|É|È|Ê|Ë', 'i' : 'í|ì|î|ï|Í|Ì|Î|Ï', 'o' : 'ó|ò|ô|õ|ö|Ó|Ò|Ô|Õ|Ö', 'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü', 'c' : 'ç|Ç', 'n' : 'ñ|Ñ' -
marcelo-ribeiro revised this gist
Jul 28, 2020 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,6 @@ function slugify (str) { 'n' : 'ñ|Ñ' }; for (var pattern in map) { str = str.replace(new RegExp(map[pattern], 'g'), pattern); }; -
marcelo-ribeiro revised this gist
Feb 10, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ function slugify (str) { '-' : '_', 'a' : 'á|à|ã|â|À|Á|Ã|Â', 'e' : 'é|è|ê|É|È|Ê', 'i' : 'í|ì|î|Í|Ì|Î', 'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ', 'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü', 'c' : 'ç|Ç', -
marcelo-ribeiro revised this gist
Feb 10, 2017 . No changes.There are no files selected for viewing
-
marcelo-ribeiro revised this gist
Feb 10, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ function slugify (str) { var map = { '-' : ' ', '-' : '_', 'a' : 'á|à|ã|â|À|Á|Ã|Â', 'e' : 'é|è|ê|É|È|Ê', 'i' : 'í|ì|î', -
marcelo-ribeiro renamed this gist
Feb 10, 2017 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ function slugify (str) { var map = { 'a' : 'á|à|ã|â|À|Á|Ã|Â', 'e' : 'é|è|ê|É|È|Ê', 'i' : 'í|ì|î', @@ -9,9 +9,11 @@ function removeAccents (str) { 'n' : 'ñ|Ñ' }; str = str.toLowerCase(); for (var pattern in map) { str = str.replace(new RegExp(map[pattern], 'g'), pattern); }; return str; }; -
Fábio Santos revised this gist
Dec 10, 2015 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,8 +4,9 @@ function removeAccents (str) { 'e' : 'é|è|ê|É|È|Ê', 'i' : 'í|ì|î', 'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ', 'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü', 'c' : 'ç|Ç', 'n' : 'ñ|Ñ' }; angular.forEach(map, function (pattern, newValue) { -
Fábio Santos created this gist
Dec 10, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ function removeAccents (str) { map = { 'a' : 'á|à|ã|â|À|Á|Ã|Â', 'e' : 'é|è|ê|É|È|Ê', 'i' : 'í|ì|î', 'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ', 'u' : 'ú|ù|û|Ú|Ù|Û', 'c' : 'ç|Ç' }; angular.forEach(map, function (pattern, newValue) { str = str.replace(new RegExp(pattern, 'g'), newValue); }); return str; };