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

222
Visualizações
Javascript regEx to remove all parentheses except between special characters

I need a regEx to remove all ( and ) from a string, except those between two @.

Example:

( [15] == @value 1@ || [15] == @value 2@ )  &&  ( [5] == @value 3 (ignore these)@ || [5] == @value 4@ )  ||  ( [2] == @value 5@ )

The string I need:

[15] == @value 1@ || [15] == @value 2@  &&  [5] == @value 3 (ignore these)@ || [5] == @value 4@  ||  [2] == @value 5@ 

I tried something with this non-capturing group to split with whitespaces except those between @ but could not find the way:

(?:@[^@]*@|\S)

I'm under pressure to solve this, any help is appreciated, thank you.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You may use this regex for matching:

\s*[()](?=(?:[^@]*@[^@]*@)*[^@]*$)\s*

And replace with just empty string.

RegEx Demo

RegEx Details:

  • \s*: Match 0 or more whitespaces
  • [()]: Match ( or )
  • (?=: Start positive lookahead
    • (?:[^@]*@[^@]*@)*: Match 0 or more pairs of @...@ substrings
    • [^@]*: Match 0 more of anything but @
    • $: End
  • ): End positive lookahead
  • \s*: Match 0 or more whitespaces
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