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

241
Vistas
Regex, matching backticks not nested within triple backticks

I'm trying to match strings that are surrounded by backtick's but they aren't surrounded by triple backtick's.

For example:

match: `I should be matched`

should not match: ``` `Hello world` ```

This is what I've tried so far: https://regex101.com/r/P4MhiM/1

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

i get pass this test case

first capture all match in single quote

\`(?:.+)\`

second filter the matchs only char not backticks nor white space

\`(?:[^\`||\s]+)\`

https://regex101.com/r/oVE7zi/1

about 4 years ago · Juan Pablo Isaza Denunciar

0

Match and capture a part of the match, then use custom logic in the replacement:

const text = "\n``` `Hello world` ```\n\n\n`Matched!`\n";
const rx = /```.*?```|`([^`\n]+)`/g;
console.log(
  text.replace(rx, (x, y) => y ? `<code>${y}</code>` : x)
)

See the regex demo. Details:

  • ```.*?``` - strings between triple backticks (with no line breaks in between backticks)
  • | - or
  • `([^`\n]+)` - strings between backticks without line break chars.
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