Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4573860
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:50:39+00:00 2026-05-21T19:50:39+00:00

I have found a regex template in Expresso, this one works fine and returns

  • 0

I have found a regex template in Expresso, this one works fine and returns perfect matches but in JavaScript it doesn’t work. I know its may be for look-behind, but I am not enough efficient in Regex to make it JS compatible.

\((?>[^()]+|\((?<number>)|\)(?<-number>))*(?(number)(?!))\)

I want to match it with …

max(50, max(51, 60)) a() MAX(s,4,455)something

… and it should return …

1: (50, max(51, 60))

2: ()

3: (s,4,455)

This works perfectly in Expresso but JS console in Chrome says:

Uncaught SyntaxError: Invalid regular expression: /\((?>[^()]+|\((?<number>)|\)(?<-number>))*(?(number)(?!))\)/: Invalid group

How can this regex be modified to function properly in JavaScript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:50:39+00:00Added an answer on May 21, 2026 at 7:50 pm

    Assuming that your given regular expression is a .NET regular expression, the following syntax components are not supported by JavaScript:

    • (?>…) – nonbacktracking subexpression
    • (?<name>…) – named matched subexpressions
    • (?<name1-name2>…) – balancing group definition
    • (?(name)…) – conditional group

    To get the same result with JavaScript, you’ll need to do the balancing on your own:

    var parts = str.match(/[()]|[^()]+/g),
        matches = [],
        balance = 0;
    for (var i=0, j=0; i<parts.length; i++) {
        switch (parts[i]) {
        case "(":
            if (balance === 0) {
                j = i;
            }
            balance++;
            break;
        case ")":
            if (balance === 1) {
                matches.push(parts.slice(j, i+1).join(""));
            }
            balance--;
            if (balance < 0) {
                throw new EvalError('parentheses are not balanced; unexpected "("');
            }
            break;
        }
    }
    if (balance > 0) {
        throw new EvalError('parentheses are not balanced; missing ")"');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found useful regex expressions from the site, but this particular one eludes
I found this regex which works fine if there are no alphabets in provided
I have found already some similar discussion on this, but would like to investigate
I have found the below Javascript recently, and (believe) I understand its operation, but
Regex is not really my thing. But i have this in my php file
I have found this Regex extractor code in C#. Can someone tell me how
I have found two ways to extract matches in Python: 1. def extract_matches(regexp, text):
I have found many great answers to this from a year ago (when it
I have found this link: http://www.jfree.org/forum/viewtopic.php?f=3&t=6314 Its back in 2007 where they agree that
I have found some jQuery codes for show content with slide effect, but none

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.