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

246
Visualizações
How to use regex lookahead with big conditions?

I want to detect things that start with @ and have a double bracket. @[uuid][displayValue]. I have the following regex for that.

@\[([^\][]*)]\[([^\][]*)]

I want to pair lookahead((?=) with it but doing that does not work.

(?=@\[([^\][]*)]\[([^\][]*)])

It does not return any match. Lookahead is to keep delimiter in javascript split function.

Consider the following example:

const text = 'I want to thank @[handle1][displayValue1], @[handle2][displayValue2] for their contribution'.

When I use text.split(/(?=@\[([^\][]*)]\[([^\][]*)])/g) with the regex, I am looking for following output

['I want to thank ','@[handle1][displayValue1]',', ','@[handle2][displayValue2],'for their contribution']
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

run the sniipet, and you get the matches with start indexes

for( let a of 'I want to thank @[handle1][displayValue1], @[handle2][displayValue2] for their contribution'.matchAll(/@\[(.*?)\]\[(.*?)\]/g)){console.log(a)}

enter image description here


if uuid/displayValue might contain @[][] like words, you will need to code more logic, probably with a finite state machine

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