Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!