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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:45:34+00:00 2026-06-01T10:45:34+00:00

This is a continuation of my previous question .NET regex engine returns no matches

  • 0

This is a continuation of my previous question .NET regex engine returns no matches but I am expecting 8.

My query is handling everything perfectly and I have my capture groups working great, however I have found a edge case that I do not know how to handle.

Here is a test case that I am having trouble with.

INSERT INTO [Example] ( [CaseNumber] , [TestText] )
VALUES
(1 , 'Single Line Case'),
(2 , 'Multi
Line Case');
(3 , 'Two Lines with odd end '');
Case');
(4 , ''),
(5 , 'Case 3 is the Empty Text Case');

Here is my pattern I am using, I use the RegexOptions flags Singleline, Multiline, ExplicitCapture, and IgnorePatternWhitespace

^\(
((('(?<s>.*?)'(?!')) |
 (?<n>-?[\d\.]+)
 )(\s,\s)?
)+
#(?<!'')   #Commented Case 3 works, un-commented case 2 works
\)[;,]\r?$

I can either handle Case 3 or Case 4 but I am having trouble handling both.

If I had a way to check to see if there was a even number of ' in the capture group ‘s` I could check then to see if we are on a real end of line or in text block that has a line that ends that just happens to match the pattern. but I can not figure out how to modify other examples to handle multiple lined text strings.

Can what I want be done with a single regex query or am I forced to do post processing (using the commented case) and do this is two passes?


Here is the code to run it in LINQPad

string text = 
@"INSERT INTO [Example] ( [CaseNumber] , [TestText] )
VALUES
(1 , 'Single Line Case'),
(2 , 'Multi
Line Case');
(3 , 'Two Lines with odd end '');
Case');
(4 , ''),
(5 , 'Case 3 is the Empty Text Case');
";

const string recordRegex =
@"^\(
((('(?<s>.*?)'(?!')) |
 (?<n>-?[\d\.]+)
 )(\s,\s)?
)+
#(?<!'')   #Commented Case 3 works, un-commented case 2 works
\)[;,]\r?$";

var records = Regex.Matches(text, recordRegex, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture);
records.Dump();
  • 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-01T10:45:35+00:00Added an answer on June 1, 2026 at 10:45 am

    An expression like this would match such quotes:

    (?:'[^']*')+
    

    If you want to match foo when it’s not inside such quotes, you could use something like:

    foo(?=[^']*(?:'[^']*'[^']*)+\z)
    

    one match per line with the unquoted text and numbers as capture groups

    Something like this:

    (?xm)^
    \(
    
    (?:
        (?:
            (?<quote> (?:'[^']*')+ )
        |   (?<num>   -?\d+(?:\.\d+)? )
        |   (?<x>     X'[0-9a-f]*' )
        )
        (?:\s*,\s*)?
    )+
    
    \)
    [;,] 
    \r?$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a continuation from the previous stackoverflow jQuery question I asked, but I
This is sort of a continuation of my previous question , but I feel
This is a continuation question from a previous question I have asked I now
This question is a continuation of my previous question here zend models architecture (big
This is in continuation to my previous question which was closed cause of similarity
This is a continuation of my previous question which I posted when I wasn't
This question is in continuation to my previous question, in which I asked about
This is a continuation from a previous stackoverflow question. I've renamed some variables so
This question is a continuation of a previous thread to compare two lists with
This is a continuation of my previous question: Could not find an implementation of

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.