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

166
Visualizações
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 Respostas
Responde à pergunta

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 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