Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save N0NameF0und/703a3a6d6e2ca921924fb7316a8f772d to your computer and use it in GitHub Desktop.

Select an option

Save N0NameF0und/703a3a6d6e2ca921924fb7316a8f772d to your computer and use it in GitHub Desktop.

Revisions

  1. @marcelo-ribeiro marcelo-ribeiro revised this gist Apr 9, 2021. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions javascript-remove-accents.js
    Original 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' : 'ñ|Ñ'
    '-' : ' ',
    '-' : '_',
    'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä',
    'e' : 'é|è|ê|ë|É|È|Ê|Ë',
    'i' : 'í|ì|î|ï|Í|Ì|Î|Ï',
    'o' : 'ó|ò|ô|õ|ö|Ó|Ò|Ô|Õ|Ö',
    'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
    'c' : 'ç|Ç',
    'n' : 'ñ|Ñ'
    };

    for (var pattern in map) {
    str = str.replace(new RegExp(map[pattern], 'g'), pattern);
    str = str.replace(new RegExp(map[pattern], 'g'), pattern);
    }

    return str;
  2. @marcelo-ribeiro marcelo-ribeiro revised this gist Apr 9, 2021. 1 changed file with 16 additions and 16 deletions.
    32 changes: 16 additions & 16 deletions javascript-remove-accents.js
    Original 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);
    }
    const map = {
    '-' : ' ',
    '-' : '_',
    'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä',
    'e' : 'é|è|ê|ë|É|È|Ê|Ë',
    'i' : 'í|ì|î|ï|Í|Ì|Î|Ï',
    'o' : 'ó|ò|ô|õ|ö|Ó|Ò|Ô|Õ|Ö',
    'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
    'c' : 'ç|Ç',
    'n' : 'ñ|Ñ'
    };

    return str;
    for (var pattern in map) {
    str = str.replace(new RegExp(map[pattern], 'g'), pattern);
    }

    return str;
    }
  3. @marcelo-ribeiro marcelo-ribeiro revised this gist Apr 9, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions javascript-remove-accents.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    function slugify (str) {
    var map = {
    const slugify = str => {
    const map = {
    '-' : ' ',
    '-' : '_',
    'a' : 'á|à|ã|â|ä|À|Á|Ã|Â|Ä',
  4. @marcelo-ribeiro marcelo-ribeiro revised this gist Apr 9, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions javascript-remove-accents.js
    Original 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;
    };
    }
  5. @marcelo-ribeiro marcelo-ribeiro revised this gist Mar 11, 2021. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions javascript-remove-accents.js
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,10 @@ function slugify (str) {
    var map = {
    '-' : ' ',
    '-' : '_',
    'a' : 'á|à|ã|â|À|Á|Ã|Â',
    'e' : 'é|è|ê|É|È|Ê',
    'i' : 'í|ì|î|Í|Ì|Î',
    'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ',
    'a' : 'á|à|ã|â|ä|À|Á|Ã|Â',
    'e' : 'é|è|ê|ë|É|È|Ê',
    'i' : 'í|ì|î|ï|Í|Ì|Î',
    'o' : 'ó|ò|ô|õ|ö|Ó|Ò|Ô|Õ',
    'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
    'c' : 'ç|Ç',
    'n' : 'ñ|Ñ'
  6. @marcelo-ribeiro marcelo-ribeiro revised this gist Jul 28, 2020. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions javascript-remove-accents.js
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,6 @@ function slugify (str) {
    'n' : 'ñ|Ñ'
    };

    str = str.toLowerCase();

    for (var pattern in map) {
    str = str.replace(new RegExp(map[pattern], 'g'), pattern);
    };
  7. @marcelo-ribeiro marcelo-ribeiro revised this gist Feb 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion javascript-remove-accents.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ function slugify (str) {
    '-' : '_',
    'a' : 'á|à|ã|â|À|Á|Ã|Â',
    'e' : 'é|è|ê|É|È|Ê',
    'i' : 'í|ì|î',
    'i' : 'í|ì|î|Í|Ì|Î',
    'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ',
    'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
    'c' : 'ç|Ç',
  8. @marcelo-ribeiro marcelo-ribeiro revised this gist Feb 10, 2017. No changes.
  9. @marcelo-ribeiro marcelo-ribeiro revised this gist Feb 10, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions javascript-remove-accents.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    function slugify (str) {
    var map = {
    '-' : ' ',
    '-' : '_',
    'a' : 'á|à|ã|â|À|Á|Ã|Â',
    'e' : 'é|è|ê|É|È|Ê',
    'i' : 'í|ì|î',
  10. @marcelo-ribeiro marcelo-ribeiro renamed this gist Feb 10, 2017. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions angularJS_removeAccents.js → javascript-remove-accents.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    function removeAccents (str) {
    map = {
    function slugify (str) {
    var map = {
    'a' : 'á|à|ã|â|À|Á|Ã|Â',
    'e' : 'é|è|ê|É|È|Ê',
    'i' : 'í|ì|î',
    @@ -9,9 +9,11 @@ function removeAccents (str) {
    'n' : 'ñ|Ñ'
    };

    angular.forEach(map, function (pattern, newValue) {
    str = str.replace(new RegExp(pattern, 'g'), newValue);
    });
    str = str.toLowerCase();

    for (var pattern in map) {
    str = str.replace(new RegExp(map[pattern], 'g'), pattern);
    };

    return str;
    };
  11. Fábio Santos revised this gist Dec 10, 2015. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions angularJS_removeAccents.js
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,9 @@ function removeAccents (str) {
    'e' : 'é|è|ê|É|È|Ê',
    'i' : 'í|ì|î',
    'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ',
    'u' : 'ú|ù|û|Ú|Ù|Û',
    'c' : 'ç|Ç'
    'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
    'c' : 'ç|Ç',
    'n' : 'ñ|Ñ'
    };

    angular.forEach(map, function (pattern, newValue) {
  12. Fábio Santos created this gist Dec 10, 2015.
    16 changes: 16 additions & 0 deletions angularJS_removeAccents.js
    Original 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;
    };