Javascript String removeSomeSpecialCharacters()

Description

Javascript String removeSomeSpecialCharacters()


'use strict';//  w w  w  .j a v a2s  . c o  m
String.prototype.removeSomeSpecialCharacters = function removeSomeSpecialCharacters () {
  var string = this;
  var mapaAcentosHex  = {
    a : /[\xE0-\xE6]/g,
    e : /[\xE8-\xEB]/g,
    i : /[\xEC-\xEF]/g,
    o : /[\xF2-\xF6]/g,
    u : /[\xF9-\xFC]/g,
    c : /\xE7/g,
    n : /\xF1/g
  };

  for ( var letra in mapaAcentosHex ) {
    var expressaoRegular = mapaAcentosHex[letra];
    string = string.replace( expressaoRegular, letra );
  }

  return string;
};



PreviousNext

Related