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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:28:20+00:00 2026-06-09T06:28:20+00:00

I have strings similar in nature to ‘foo = bar’ . Right now when

  • 0

I have strings similar in nature to 'foo = "bar"'. Right now when I am testing if these strings pass a certain regular expression, I am testing the quotes around ‘bar’ with ["|']?, making the full RegEx in that area something along the lines of ["|']?(\w+)["|']? (I am stripping out irrelevant expression parts for readability).

This means several things:

  • The quotes around the word can be double quotes, single quotes, or nonexistent.
  • Regardless of which they are, they are not “linked”. If a double quote is used on the left and no quote on the right this will still pass, etc.

My goal is to match the second quote based on the first. I would very much like to implement this entirely with RegEx, though I understand I am approaching the limits of what it can do (as far as the JavaScript implementation goes). I am quite familiar with lookaheads/behinds, but as I understand it these would only be relevant if the quotes were touching. I am hoping that I understand them incorrectly.

P.S.: I am only worried about modern browsers, so IE<10 support is a non-issue.

P.P.S: I mentioned that I would like to do this with RegEx. Please save yourself effort and do not give an alternative. A “you cannot do this” would suffice.

  • 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-09T06:28:22+00:00Added an answer on June 9, 2026 at 6:28 am

    You could write:

    /(["'])\w+\1/
    

    \1 will only match a string that’s identical to what the first capture-group ((["'])) captured.

    Note that I removed the pipe character | from the character class ["'], because it seemed to be an error: the pipe character does not have any special meaning inside a character class. ["|'] is only correct if you want to be able to match e.g. |bar|.

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

Sidebar

Related Questions

I have some ugly strings similar to these: string1 = 'Fantini, Rauch, C.Straus, Priuli,
I have a list of strings similar to this list: tags = ('apples', 'apricots',
I have search strings, similar to the one bellow: energy food olympics 2010 Terrorism
I need to create a ranking of similar strings in a table. I have
I have strings like these: something something [[abcd]] blah blah something something [[xyz|abcd]] blah
I have 1000's of strings similar to CN=Joe Smith,OU=Students,DC=Domain,DC=Edu and I want to find
I have several rows with strings similar to this: 1,19|11|14,2 The info I want
I have collection of similar strings for example : string 1: Customer's first Name
I have strings formatted similar to the one below in a Java program. I
Let's say I have 2 strings AAABBBCCCCC and AAAABBBBCCCC to make these strings as

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.