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

170
Vistas
Ruby text variable with \ inside

I need to create a db record with a column with this value

query = "booster pro 12\24 v" 

but this is what stored into db column.

"booster pro 12\u0014 v"

if I try with single-quoted I get

'booster pro 12\24 v' -> "booster pro 12\\24 v"

but If I use this, I got the correct string printed.

puts 'booster 12\24 v' -> booster 12\24 v
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If I try with single-quoted I get

'booster pro 12\24 v' -> "booster pro 12\\24 v"

This is correct. You've already got the right answer.

A backslash is an escape character. When displaying escape characters in a double-quoted string, you must escape them with a backslash. That means a literal backslash is represented by two backslashes.

Two literal backslashes would be represented by four backslashes, in a double-quoted string.

Or for example, consider:

  • How would you display a newline character? Answer: "\n"
  • How would you display a backslash character, followed by an "n"? Answer: "\\n"

This behaviour is not specific to ruby.

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