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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:16:30+00:00 2026-06-03T23:16:30+00:00

I want to write a regular expression which can match following specification for string

  • 0

I want to write a regular expression which can match following specification for string literals. For the last 10 hours, I’ve gone crazy over formulating various regular expressions which none seem to work. Finally I’ve boiled down to this one:

  • ([^"]|(\\[.\n]))*\"

Basically, requirements are following:

  1. A String literal has to be matched so I’m matching everything upto the last “, in between there could be a \”, which should not end the string.
  2. We could also be able to escape anything including a \n with a ‘\’
  3. Only an unescaped ‘”‘ character can end the match, nothing else.

Some sample strings which I need to correctly match are following:

  1. \a\b\”\n” => I should match following character ‘\’, ‘a’, ‘\’, ‘b’, ‘\’,'”‘,’\’, ‘n’, ‘”‘
  2. \”this is still inside the string” => should match whole text including last ‘”‘
  3. ‘m about to escape to a newline \’\n'” => There’s a \n character in this string, but still the string should match everything from starting ‘m’ to ending ‘”‘.

Kindly someone please help me formulate such a Regex. In my opinion that Regex I’ve provided should do the job, but it’s rather failing for no reason.

  • 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-03T23:16:31+00:00Added an answer on June 3, 2026 at 11:16 pm

    Your regular expression is almost right, you just need to be aware that inside a character class the period . is just a literal . and not any character except newline. So:

    ([^"\\]|\\(.|\n))*\"
    

    Or:

    ([^"\\]|\\[\s\S])*\"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a regular expression that will match the following string a
How to write regular expression where we can find all words which are started
I don't understand, why does the following regular expression: ^*$ Match the string 127.0.0.1?
I want to write a regular expression in F# that represents strings which start
I write regular expression for alphanumerics, but it is not taking space. I want
I'm trying to write a regular expression which should be able to identify boolean
I'm stuck with a regular expression problem. I've got a string which I need
I am trying to write a regular expression to match file paths with the
I want to write a function validate() which will take some pattern or regular
Is it possible to write code which generates a regular expression or XPath that

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.