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

301
Visualizações
Add missing opening / closing quotation mark (fix user error)

I am trying to build a small utility in javascript that can fix user input errors. The user is supposed to enter a string in the following format:

example: object1:"key1 key2" object2:"key3 key4" object2:"key5" object2:"key6 key7" What I am trying to create is a logic that will find missing quotation marks (either opening or closing) on the keys, in case the user forgot to add it.

possible error case would be: object1:"key1 object2:"key2" which should be fixed with by adding a closing " to the key1 object.

I'm a coding beginner and I am not looking for a ready solution, but helpful suggestions how I can approach this. Thank you so much!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you are only concerned about the missing quotation marks and that the input string strictly only has missing quotation marks and follows your example format, one approach is to split the input in every colon character.

After that, you can loop through the array starting at the second element and check if the beginning of every string has opening quotation marks and if the characters before the object names are a quotation mark and a space. If not, add a opening/closing quotation mark.

After adding necessary quotation marks, you can just join the string back.

Again, that is if there are no other possible cases/scenarios that are needed to be checked, otherwise, you need to create a string parser that satisfies all possible cases.

about 4 years ago · Juan Pablo Isaza Relatório
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