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

115
Vistas
JS equivalent for Golang's strconv.Quote

Given a YAML like this:

--- 
body: "something else"
path: site:^example\.com?"something"..."something"
title: "How to do this"

parsing it using yaml-ast-parser, it results in an invalid YAML because to he period in the regex and the quotes. I can extract the value of path and double quote it with strconv.Quote and that results in a final YAML like this:

--- 
body: "something else"
path: "site:^example\\.com?\"something\"...\"something\""
title: "How to do this"

However, strconv.Quote is a golang method and this is a javascript project. Does anyone know a way I can achieve strconv.Quote in a javascript environment.

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

0

To get something similar to strconv.Quote, use JSON.stringify:

// Example value you got from the YAML:
const path = String.raw`site:^example\.com?"something"..."something"`;

console.log("before");
console.log(path);
console.log("after");
console.log(JSON.stringify(path));

about 4 years ago · Santiago Gelvez 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