Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!