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

168
Vistas
Get two string from a multilines data in javascript

I tried to get 2 string from multilines data. I used Reguler Expression to match the string that I want. First string is just one line, but the second is multipleline. This is my RegEx function

const RegExp = /\/Data first:(.*) second:(.*\n.*)/
const first = RegExp.exec(text)[1]
const second = RegExp.exec(text)[2]

I have the following string

/Data first:this first must include second:this second and
third
fourth
.
.
.
and so on must include

But it's not working as I expected. What I got is like this

first: this first line
second: this second
third

But I need to get result is like this

first: this first line
second: this second
third
fourth
.
.
.
and so on

I tried a lot of things, but I can't figure it out.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can try this \/Data first:(.*) second:(.*[\s\S]*). I tested with your data and it's working as your requirement. You can try this playground.

https://regex101.com/r/a4bJIH/1

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