Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
How to distinguish between single slash for escaping vs windows file path?

I have a logger class in my JavaScript that has the following line at some point:

// some function class that has `msg: string` variable
msg = msg.replace(/\\/g, '');

My logger has some syntax such as --some string-- that gets a markup. But if someone wants to actually print -- then they would escape it with "\\-\\-some string\\-\\-".

Now this all works well. However, on a Windows machine, file paths use \ and when I try to print for example logger.info(process.cwd()), that line msg.replace(/\\/g, '') replaces all the slashes in the path and I end up getting something like C:userskoushadocumentsnode_modules

How can I handle both windows file path and the ability to escape characters?

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda