Guest User

Untitled

a guest
Jan 24th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. let umlautMap = {
  2. 'u00dc': 'UE',
  3. 'u00c4': 'AE',
  4. 'u00d6': 'OE',
  5. 'u00fc': 'ue',
  6. 'u00e4': 'ae',
  7. 'u00f6': 'oe',
  8. 'u00df': 'ss',
  9. }
  10.  
  11. function replaceUmlaute(str) {
  12. return str
  13. .replace(/[u00dc|u00c4|u00d6][a-z]/g, (a) => {
  14. var big = umlautMap[a.slice(0, 1)];
  15. return big.charAt(0) + big.charAt(1).toLowerCase() + a.slice(1);
  16. })
  17. .replace(new RegExp('['+Object.keys(umlautMap).join('|')+']',"g"),
  18. (a) => umlautMap[a]
  19. );
  20. }
Add Comment
Please, Sign In to add comment