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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:16:15+00:00 2026-05-22T03:16:15+00:00

I have a regexp of the form: /(something complex and boring)?(something complex and interesting)/

  • 0

I have a regexp of the form:

/(something complex and boring)?(something complex and interesting)/

I’m interested in the contents of the second parenthesis; the first ones are there only to ensure a correct match (since the boring part might or might not be present but if it is, I’ll match it by accident with the regexp for the interesting part).

So I can access the second match using $2. However, for uniformity with other regexps I’m using I want that somehow $1 will contain the contents of the second parethesis. Is it possible?

  • 1 1 Answer
  • 1 View
  • 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-22T03:16:16+00:00Added an answer on May 22, 2026 at 3:16 am

    Use a non-capturing group:

    r = /(?:ab)?(cd)/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's something I couldn't find an answer to. Say you have a form and
I have a user registration form and I only want the user to specify
i have problem in javascript email validation, I wrote code something like, //emp.php <form
I have regexp to change smileys to images. Here it is (?:(?![0]:\)|:\)\)|:-\)\)))(:\)|:-\)) The point
Bear with me, as I'm quite new to using regular expressions. I have regexp
I have a regexp to validate file names. Here is it: /[0-9a-zA-Z\^\&\'\@\{\}\[\]\,\$\=\!\-\#\(\)\.\%\+\~\_ ]+$/ It
I have a RegExp Tester extension in chrome. Running pattern [-,] against search text
I have this regexp: $f =~ s/[.\W_]//g; which keeps just the numbers, letters and
let's say I have two regexp's, /eat (apple|pear)/ /I like/ and text I like
I am reading one file using ruby in which I have written regexp in

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.