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 8464073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:37:52+00:00 2026-06-10T14:37:52+00:00

I understand the .split() function quite well. But what I can seem to figure

  • 0

I understand the .split() function quite well. But what I can seem to figure out is how to split in certain places but not in others. Sounds confusing? Well I mean for example, lets say I use .split(",") on the following string:

div:(li,div),div

Is it possible to split it so that only the commas ouside of the parentheses get split.

So the string above with the split method should return:

['div:(li,div)', 'div']

Of course at the moment it is also splitting the first comma inside of the parentheses, returning:

['div:(li', 'div)', 'div']

Is there some way to make this work like I desire?

  • 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-10T14:37:54+00:00Added an answer on June 10, 2026 at 2:37 pm

    If your expected strings are not going to become more complicated than this, you don’t have to worry about writing code to parse them. Regex will work just fine.

    http://jsfiddle.net/dC5HN/1/

    var str = "div:(li,div),div:(li,div),div";
    var parts = str.split(/,(?=(?:[^\)]|\([^\)]*\))*$)/g);
    console.log(parts);
    

    outputs:

    ["div:(li,div)", "div:(li,div)", "div"] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't understand why in the url_split function I can use a++ , but
I try to understand the regex in python. How can i split the following
I think I understand OSPF - it is Link-State routing, with a domain split
Given the Ruby code line = first_name=mickey;last_name=mouse;country=usa record = Hash[*line.split(/=|;/)] I understand everything in
I understand this is an easy question but for some reason this just isn't
I understand I can create an enum like this: public enum MyEnum { ONE(1),
I understand what weak tables are. But I'd like to know where weak tables
I wrote this function that does this (easier to show than explain): (split 2
i understand that the code given below will not be compltely understood unless i
Ok, so here's the skinny... I've worked out a jQuery function that will first

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.