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

  • SEARCH
  • Home
  • 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 7994405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:07:22+00:00 2026-06-04T14:07:22+00:00

I posted this question a while back which was answered well: Complex regex to

  • 0

I posted this question a while back which was answered well:
Complex regex to split up a string

I know have a new conundrum related to it, and I’m really not getting anywhere…

Say I now have a string like this:

{foo.bar:/?a{3\}}{blah}

Using the code supplied in the previous post it does this:

{foo.bar:/?a
{3\}}
{blah}

I want it to do this:

{foo.bar:/?a{3\}}
{blah}

This is because now I have to deal with strings that don’t have an escape before the second curly brace in the example. I need some code that can spot when to ignore certain opening curly braces. Eg. If reading along the string from left to right it sees the first opening curly brace, then when it sees the second opening curly brace it kinda says ‘hang on, I haven’t seen a valid closing curly brace yet, so I am going to ignore this’. Is this possible? I understand that it may not entirely possible using purely regex.

This is the initial part of the code I am using from the previous question which is causing the issue:

var m = str.match(/{?(\\.|[^{}])+}?/g);

Or another solution might be that when the user is typing & submitting the string beforehand, it slips in an escaping backslash without the user seeing it. The trouble with this is knowing which escaping backslashes to ‘hide’ again from the user…

  • 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-06-04T14:07:23+00:00Added an answer on June 4, 2026 at 2:07 pm

    What about something like this?

    var str = "{foo.bar:/?a{3\}}hello?{blah}world{blah2}";
    
    var rgx = new RegExp(/}(?!})+[^{]*{/g); 
    
    str = str.replace(rgx,"},{");
    
    //document.write(str + "<br/>");
    
    arr = str.split(",");
    
    for(i=0; i<arr.length; i++) {
        document.write(arr[i] + "<br/>");
    }
    

    The key here is the regex /}(?!})+[^{]*{/g

    } literal character match

    (?!})+ asserts that, following the previous match, at least one } isn’t matched.

    [^{]* matches any number of characters excluding {

    { literal character match

    See it working here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I little while back I posted this question . I have updated that question
A while back I posted a different question regarding column order. While this question
This is a follow-up to a question I posted a while back: Can I
I have posted this question a while ago but got a partial answer to
This question is related to this question I asked a little while back. The
I have a nice polynomial, which is in fact the non-posted answer to this
i'm trying to print out a string of UTF-16 characters. i posted this question
I posted this question a while ago regarding where to store non-user specific application
I posted a similar question a while back and now as I need to
I posted this question on Reddit Programming and did not get a single response.

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.