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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:20:11+00:00 2026-05-25T20:20:11+00:00

I am creating a Regex and so far I did this and tried it,

  • 0

I am creating a Regex and so far I did this and tried it,

 ^([0][1-9]|1[0-2])[/-.]

and I get the following error.

      parsing "^([0][1-9]|1[0-2])[/-.]" - [x-y] range in reverse order. 
      Description: An unhandled exception occurred during the execution of the current web request.          
      Please review the stack trace for more information about the error and where it originated in  
      the code. 

      Exception Details: System.ArgumentException: parsing "^([0][1-9]|1[0-2])[/-.]" - [x-y] range 
      in reverse order.

After messing around for a bit and trying to find error in my regex I simply changed me regex to

  ([0][1-9]|1[0-2])[-/.]  so basically only changed this [/-.] to [-/.]

and it worked.

Then I tried some other combinations which worked.

   [/-]  [/.]  [/.-]  [/-?]

Then I tried some others which didn’t work.

   [/-\*]  [/-\+]

So apparently “-” has problem at some places but no problem at others. Is that a bug? or am I missing something?

Update

Thanks guys for pointing out that “-” is assumed as range if it is in middle or not escaped by “\”.

However, why did it work for [/-?] or [/-\?], is it really defining range here or taking it literally?

  • 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-25T20:20:11+00:00Added an answer on May 25, 2026 at 8:20 pm

    Not a bug. Inside a character class (denoted by […]) the - character must be first (some flavours allow first or last, I believe) if it is to be included as a literal. Otherwise it is expected to denote a range, such as 0-9 or A-Z or even /-..

    The problem is that according to Unicode, the . comes before the /, so the range is interpreted to be backward, equivalent to specifying a range 7-4.

    If you used [.-/], I would not expect a parse exception, but you wouldn’t get the results you expected.

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

Sidebar

Related Questions

Can someone assist in creating a Regex for the following situation: I have about
So why is this not working? I'm creating a regex that will match a
I've tried creating the regex I need, but even after half an hour I
While creating a new spring template project, I keep getting the following error -
I was creating a regex for following condition a string can contain any alphabet,
Creating some regex expressions here. I was wondering if I could get some pointers
I'm am not really good with creating complex RegEx. I copied the following from
I am creating a regex library to work with HTML (I'll post it on
I'm creating a javascript regex to match queries in a search engine string. I
When trying to use boost regex library by #include'ing boost/regex.hpp and then creating object

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.