daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest May 25th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var normalizar = function(str, espaciosEnBlanco) {
  2.   if(!espaciosEnBlanco) espaciosEnBlanco = '';
  3.   str = str.toLowerCase().replace(/\s+/g, espaciosEnBlanco);
  4.   //Sustituimos caracteres extraños
  5.   var from = "àáäâèéëêìíïîòóöôùúüûñç";
  6.   var to   = "aaaaeeeeiiiioooouuuunc";
  7.   for (var i=0, l=from.length ; i<l ; i++) {
  8.     str = str.replace(
  9.       new RegExp(from.charAt(i), 'g'),
  10.       to.charAt(i)
  11.     );
  12.   }
  13.   //eliminamos otros caracteres inválidos
  14.   str = str.replace(new RegExp('[^a-z0-9'+ espaciosEnBlanco +']',"g"), '').replace(/-+/g, espaciosEnBlanco);
  15.   return str;
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top