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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:30:24+00:00 2026-06-15T04:30:24+00:00

I came across the following regex at work. What does it do? ,(?=(?:[^\]*\[^\]*\)*(?![^\]*\)) To

  • 0

I came across the following regex at work. What does it do?

,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))

To understand it, I split it into following parts

  • , = Match everything that has ,

  • (?= = Followed by

  • (?:[^\"]*\"[^\"]*\")* = Anything which does not match ", followed by ", followed by anything which does not match ", followed by ". For example, 1111″aaaaa”

  • (?![^\"]*\") = BUT not followed by anything that does not " and matches "

In other words, match anything that has , followed by either 11111"111" OR followed by ""

The use case where the above expression is used, simply for tokenizing a string, separated by ,, but I am assuming the author built for some thing more generic.

Can anyone provide a more simpler explanation than above?

The above expression is used to assign expression to boost::regex().

UPDATE:
Actually, it is searching for the “,” commas, with the following constraint

  1. It is okay that there are even number of ” following the comma

  2. BUT, It is NOT okay to have a single ” following the comma

For example consider the string: a, “h,w”, 23

The first “,” is matched, because it has following even number of ” (“h,w”)

The second “,” in between “h,w” is NOT matched because of the second expression (?![^\”]*\”) which states that a “,” should not be followed by a single “

Finally the last “,” matches.

The final output would be 2 , ,

  • 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-15T04:30:26+00:00Added an answer on June 15, 2026 at 4:30 am

    It looks like it will match any comma, but only if there are an even number of " characters after that comma.

    , – A comma.

    (?= – Followed by…

    (?:[^\"]*\"[^\"]*\")* – Any string ending in a " mark and containing an even total number of " marks, or the empty string,

    (?![^\"]*\") – and there is no other " mark later on in the string.

    ) to close the (?=.

    This could be useful if we already know that the entire input string has an even total of " characters, there’s no such thing as nesting or escaping quotes, and commas between quote marks should not be treated as delimiters. For example, given the input

    25,"Hello, world!","More text",123.45
    

    the regex should not match the comma between Hello and world, but should match the other three commas.

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

Sidebar

Related Questions

I came across following code and don't know what does having from twice mean
I came across the following code that compiles fine (using Visual Studio 2005): SomeObject
I came across the following code in a book recently. It says that we
I came across the following C puzzle: Q: Why does the following program segfault
I came across following code function currentSlideFromParams() { var result; if (result = window.location.hash.match(/#([0-9]+)/))
I'm trying to understand the basic of WCF, when I came across following question:
I came across the following script, and do not understand the first line. It
I came across the following code : int i; for(; scanf(%s, &i);) printf(hello); As
I came across the following question : How many times will the following for
I came across the following expression in someone else's code. I think it's terrible

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.