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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:50:51+00:00 2026-06-12T07:50:51+00:00

I have the expression already written, but whenever I run the code I get

  • 0

I have the expression already written, but whenever I run the code I get the entire string and a whole bunch of null values:

Regex regex = new Regex(@"y=\([0-9]\)\([0-9]\)(\s|)\+(\s+|)[0-9]");
Match match = regex.Match("y=(4)(5)+6");

for (int i = 0; i < match.Length; i++)
{
    MessageBox.Show(i+"---"+match.Groups[i].Value);
}

Expected output: 4, 5, 6 (in different MessageBoxes

Actual output: y=(4)(5)+6

It finds if the entered string is correct, but once it does I can’t get the specific values (the 4, 5, and 6). What can I do to possibly get that code? This is probably something very simple, but I’ve tried looking at the MSDN match.NextMatch article and that doesn’t seem to help either.

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-06-12T07:50:52+00:00Added an answer on June 12, 2026 at 7:50 am

    As it currently is, you don’t have any groups specified. (Except for around the spaces.)

    You can specify groups using parenthesis. The parenthesis you are currently using have backslashes, so they are being used as part of the matching. Add an extra set of parenthesis inside of those.

    Like so:

    new Regex(@"y=\(([0-9]+)\)\(([0-9]+)\)\+([0-9]+)");
    

    And with spaces:

    new Regex(@"y\s*=\s*\(([0-9]+)\)\s*\(([0-9]+)\)\s*\+\s*([0-9]+)");
    

    This will also allow for spaces between the parts to be optional, since * means 0 or more. This is better than (?:\s+|) that was given above, since you don’t need a group for the spaces. It is also better since the pipe means ‘or’. What you are saying with \s+| is “One or more spaces OR nothing”. This is the same as \s*, which would be “Zero or more spaces”.

    Also, I used [0-9]+, because that means 1 or more digits. This allows numbers with multiple digits, like 10 or 100, to be matched. And another side note, using [0-9] is better than \d since \d refers to more than just the numbers we are used to.

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

Sidebar

Related Questions

So far I have the expression: http://[^\.]*\.mydomain\.com/((.*?)) Which matches... http://www.mydomain.com/Images/favicon.ico But I really dont
This may have been asked already, but I can't find it, so here goes.
I'm almost embarrassed to ask, but just almost. I seem to have an expression
Why do we have to spend more $$$ for Expression Blend after I already
I have a regular expression which works for validating UK postal codes but now
i have a problem to get the whole query from the url using the
There have already been some questions about this topic (for instance Expression.Invoke in Entity
I have a string that matches this regular expression: ^.+:[0-9]+(\.[0-9]+)*/[0-9]+$ which can easily be
Maybe here is already such question, but I didn't find it. I have MVVM
I have expression blend trial version 4.0.30816.0 and there is no intellisense for the

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.