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

159
Vistas
Javascript Regex to find a word started with or followed by anything other than a character or digit

I'm trying to find names of programming languages in text, I've tried for days to find the correct regex, but I can't find it. Also running into problems when the language is C++ or C# I want to match the name of the languages if it starts with or ends with anything other than letters or digits.

  reg = new RegExp("\\b[\\+" + language[element] + "] \\b", "gi");
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use

new RegExp("(?<!\\w)" + language[element].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + "(?!\\w|\\+{2}|#)", "gi");

See the regex demo if language[element] holds the C text. Details:

  • (?<!\w) - no word char allowed immediately before the current location
  • C - a C char
  • (?!\w|\+\+|#) - a negative lookahead that fails the match if there is a word char, or ++ or a # char immediately to the right of the current location.
about 4 years ago · Juan Pablo Isaza 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