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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:25:00+00:00 2026-06-16T05:25:00+00:00

I need a regular expression to find the single quotes in (Anand’s & boy’s)

  • 0

I need a regular expression to find the single quotes in (Anand’s & boy’s) of the below scenario,

'This has to be Anand's first task', 'A boy's friend works in France'

Consider I have many fields to be inserted in to DB like what I have shown in the example above.

I have error with the queries which has a single quote in its text. I need to find them and replace with ” two single quotes for this to solve.

Can you help me in writing the regex for this purpose? As I do not have much insight on regEx.

  • 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-16T05:25:02+00:00Added an answer on June 16, 2026 at 5:25 am

    You should rather be working on how to make sure that you don’t get these obviously incorrect quotes in your input in the first place. But if you can’t, you have a fighting chance by finding quotes that are not followed by a comma (or end of string) and are not preceded by a comma (or start of string):

    String resultString = subjectString.replaceAll("(?<!^|, ?)'(?!,|$)", "''");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find a regular expression which pulls out a value from a
I need to find a regular expression which will support the following format .[A-Z-a-z]/-
I need a regular expression that would let me validate Url. I found this
I need a regular expression that will match the first letter of a song
I need a regular expression to find a number in the range [40010-40100]. I
I need a regular expression to find out whether or not a h1 tag
Need a regular expression to find the text between the following two examples disregarding
is it possible to get a regular expression that do: find first occurence of
I need a regular expression find and replace that I'm a little stuck on.
I need a regular expression to find all the lines that begins with /*

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.