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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:13:37+00:00 2026-05-23T07:13:37+00:00

i tried to use Regex in c# , but the following code throws an

  • 0

i tried to use Regex in c# , but the following code throws an exception:

string pattern = "(\d+)([+*/-])(\d+)";

Regex reg = new Regex  (pattern);

After a little dig , i found that in c# if you try to match ‘-‘ with [] expression , it must be put as the first character in that bracket , which confused me.

Could someone jump out and explain that to me ?

Appreciate any of your responses.

  • 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-05-23T07:13:37+00:00Added an answer on May 23, 2026 at 7:13 am

    The - character takes on a special meaning within a character class [...] to denote a range, so that shorthand expressions like the following work:

    "[a-z]" // matches all lowercase alphabetic characters without having to specify them all.
    

    The - is only interpreted literally if it is the first character simply because it can’t denote a range because no other value precedes it.

    Honestly, it should make no difference whether it is the first or the last character.

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

Sidebar

Related Questions

I have tried to use the following regex expression to remove html whitespace and
I tried to use DriveInfo.IsReady, but it returns false if an unformatted floppy is
What should i use to code Classic ASP under Linux. I have really tried
I tried to use this on my class library mylib.core.data.dll and got a successful
I tried to use OPTION (MAXRECURSION 0) in a view to generate a list
I have tried to use ASP.NET MVC for a while, then I face a
Has anybody tried to use JavaFX Script in server side applications? The language itself
I have tried to use some of the widgets in JQuery UI on an
I have a DLL that I want to profile.. I tried to use Very
I tried recently to use NAnt (beta 0.86.2962.0) to run some unit tests compiled

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.