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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:11:14+00:00 2026-05-16T01:11:14+00:00

Problem that i face: -I have an input string, a SQL statement that i

  • 0

Problem that i face:

-I have an input string, a SQL statement that i need to parse

-extract the value that need to be insert base on the column name specify

-i can extract the value that is wrap in between 2 single quotes, but:

–?what about value that has no single quotes wrap at them? (like: integer or double)

–?what if the value inside already has single quotes? (like: ‘James”s dictionary’)

Below is the sample input string:

INSERT INTO LJS1_DX (base, doc, key1, key2, no, sq, eq, ln, en, date, line) 
VALUES ('GET','','#000210','','   0','   1','5',1,0,'20100706','Street''James''s dictionary')

The Java Code i have below match value between two single quotes only:

 Pattern p = Pattern.compile("'.*?'");
 columnValues = "'GET0','','#000210','','   0','   1','5',1,0,'20100706','Street''James''s dictionary'";
 Matcher m = p.matcher(columnValues); // get a matcher object
 StringBuffer output = new StringBuffer();
 while (m.find()) {
  logger.trace(m.group());
 }

Appreciate if anyone can provide any guideline or sample to this question.

Thank you!!

  • 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-16T01:11:15+00:00Added an answer on May 16, 2026 at 1:11 am

    I agree with gnibbler that this is a job for a csv parser.

    A regex that works on your example would be

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

    which looks challenging to debug and maintain, doesn’t it?

    Explanation:

    '            # First alternative: match an "opening" '
     (?:         # followed by either...
      ''         # two ' in a row (escaped ')
     |           # or...
      [^']       # any character that is not a '
     )*          # zero or more times,
    '            # then match a "closing" '
    |            # or (second alternative):
    [^',\s]+     # match any run of characters except ', comma or whitespace
    

    It also works if there is whitespace around the values/commas (and will leave that out of the match).

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

Sidebar

Related Questions

I have face a problem that all my app in my iphone is not
I was analyzing my situation and I face with the problem that I need
I have a problem that is staring me in the face but I cannot
I have previous experience with MATLAB, but the problem that I face is some
The problem that I have is somehow very specific. I have to implement a
I have a problem that I'm working on for quite some time now. I
Seems to be a problem that many people have, but all the answers I
I'm facing a problem that I can summarize as it follows: I have a
I have the same problem that is listed in the following thread. WSDL first
I have a big problem that a recursive treeview doesn't update any childs if

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.