Created
August 2, 2017 20:52
-
-
Save rcesar/570bc55145961ecac609ff70b1ea710f to your computer and use it in GitHub Desktop.
This file contains 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 characters
AccentsUtils = { | |
accents: { | |
a: 'àáâãäåæ', | |
c: 'ç', | |
e: 'èéêëæ', | |
i: 'ìíîï', | |
n: 'ñ', | |
o: 'òóôõöø', | |
s: 'ß', | |
u: 'ùúûü', | |
y: 'ÿ' | |
}, | |
chars : /[aceinosuy]/g, | |
stringAccentsToRegex : function(input){ | |
var self = this; | |
input = input.toLowerCase(); | |
return input.replace(self.chars, function(c){ | |
return '[' + c + self.accents[c] + ']'; | |
}); | |
} | |
}; | |
AccentsUtils.stringAccentsToRegex('relogio'); | |
//"r[eèéêëæ]l[oòóôõöø]g[iìíîï][oòóôõöø]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment