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

197
Visualizações
VueJS: How to remove first and last quotation marks of a user submitted string?

I have a VueJS app with a form with pre-populated data. A textarea element has some data like so shown on the UI

Note: (sorry I do not have enough rep points yet to attach screen shot):

screenshot of UI text area element with quote marks

I can't modify the way the backend is serving the data.

Thus, is there a good way where I can remove the FIRST and LAST quotation marks from a string? I dont' want to touch the inner text in case the user is adding quote marks within.

Expected output of 'Hello World, welcome to "fooWorld!"' shall be Hello World, welcome to 'fooWorld!'

Here's a real world example of how I am using the data in my SPA:

data() {
    return {
        entryNotes: this.post.entryNotes  //<--- this is the data I need to format
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

How about a quick regex to get rid of start and end quotes?

data(){
    return {
        entryNotes: this.post.entryNotes.replace(/^"/,"").replace(/"$/,"")
    }
}

The first regex looks for the start of the string (symbolized by ^) and then a quotation mark. The second regex looks for a quotation mark and then the end of the string (the end of string is symbolized by $).

You could also do this:

str.match(/^"?(.+?)"?$/)[1]

This one looks for the start of the string (^) followed by a ", but the ? makes it optional. Then the parenthesis captures .+ which means match anything. The ? before the end of the parenthesis means stop matching as soon as you can. Then it says look for a quotation mark, but the next question mark says "possibly", then look for the end of the string ($).

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