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

254
Vistas
Kotlin split string in the last space

I have a String and i want to split it , and drop the last part .

For example something like that for this input :

var example = "Long string to split in the last space"

I want to achieve this result

var result = "Long string to split in the last"
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Use substringBeforeLast:

"Long string to split in the last space".substringBeforeLast(" ")
over 4 years ago · Santiago Trujillo Denunciar

0

A more verbose alternative to substringBeforeLast that works for removing the last n words by using dropLast:

var example = "Long string to split in the last space"
var result = example.split(" ")
                    .dropLast(1)
                    .joinToString(" ")
println(result) // Long string to split in the last
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