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

645
Vistas
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
    }
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

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 ($).

over 4 years ago · Santiago Trujillo 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