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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:33:34+00:00 2026-06-03T02:33:34+00:00

I need to match the Date string to be 1 or 2 numbers. [StringLength(2)]

  • 0

I need to match the Date string to be 1 or 2 numbers.

 [StringLength(2)]
 [RegularExpression(@"\d{1,2}", ErrorMessage = "Date must be 1- 2 numbers")]
 public string Date { get; set; }

I will need to do similar with Year to match 4 digit character string.
What am I doing wrong here please ?

  • 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-03T02:33:36+00:00Added an answer on June 3, 2026 at 2:33 am

    There is a similar question with accepted answer on so question, it checks for a valid year. It has more validations in answers if you need them.

    Regex isn’t language dependant so if you need you can just check the web for correct one in any language. If you want to learn how to write them you can check out website, there is an application where you can test your regex.

    For date, check out date regex, or if you just want the answer:

    (0[1-9]|[12][0-9]|3[01])$
    

    It checks date from 01 to 31

    For year

    (19|20)\d\d
    

    Matches 1900-2099 😀

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

Sidebar

Related Questions

I need to match the last integer in a string and capture possible elements
I need to match input strings (URLs) against a large set (anywhere from 1k-250k)
I have a date in the string format in a table and I need
I need to convert a date to a string. The date is entered as
I have a table like this- event (id,name,date) I need a result set like
I need to match this and extract the value from these tags. Problem is
I need to match the abcd in text which may contain: abcd ssss ffff
I need to match an alphanumeric word. It can contain - but not at
I need to match contents of a list with a given pattern, and form
I need to match a image url like this: http://site.com/site.com/files/images/img (5).jpg Something like this

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.