Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

337
Vistas
Removing Special Character in JavaScript

string = string.replace(/[^a-zA-Z0-9]/g, '');

Can anyone Explain this snippet (/[^a-zA-Z0-9]/g, '') ??? What it means? I know what it does. But how

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The snippet

string = string.replace(/[^a-zA-Z0-9]/g, '');

Uses RegEx (Regular Expression) to find a paten and then replace it.

This is how it works:

  1. The .replace function replaces a specific character or patern in a string (first argument) with another (second argument)
  2. The /[^a-zA-Z0-9]/g is the regex. a-z means lower case characters from a-z, A-Z means upper case characters from a-z and 0-9 means number characters from 0-9. The ^ means not, so, not a letter, uppercase letter or number. The g at the end stands for global meaning it will not just find one match for the patern but all the matches
  3. The empty string is what to replace the patern with. So if it is not a upper/lower case letter or number character it will be replaced with nothing

Read about RegEx here

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda