Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Regex for MM/YYYY date format

Regex for MM/YYYY date format

Scheduled Pinned Locked Moved C#
regexhelp
10 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mninawa
    wrote on last edited by
    #1

    Hi Guys, Can someone help me,i need help with Regex.I want to validate a date in this format MM/YYYY,thus 02/2009, Regards Mninawa

    M M P P 4 Replies Last reply
    0
    • M Mninawa

      Hi Guys, Can someone help me,i need help with Regex.I want to validate a date in this format MM/YYYY,thus 02/2009, Regards Mninawa

      M Offline
      M Offline
      Michael Bookatz
      wrote on last edited by
      #2

      http://www.lmgtfy.com/?q=validate+a+date+in+this+format+MM%2FYYYY+regex[^] That will point you in the right direction!

      N 1 Reply Last reply
      0
      • M Michael Bookatz

        http://www.lmgtfy.com/?q=validate+a+date+in+this+format+MM%2FYYYY+regex[^] That will point you in the right direction!

        N Offline
        N Offline
        Nagy Vilmos
        wrote on last edited by
        #3

        ooo! you're good! :)


        Panic, Chaos, Destruction. My work here is done.

        M 1 Reply Last reply
        0
        • M Mninawa

          Hi Guys, Can someone help me,i need help with Regex.I want to validate a date in this format MM/YYYY,thus 02/2009, Regards Mninawa

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          how about... ^(0[1-9]|1[0-2])/[0-9]{4}$

          Life goes very fast. Tomorrow, today is already yesterday.

          1 Reply Last reply
          0
          • N Nagy Vilmos

            ooo! you're good! :)


            Panic, Chaos, Destruction. My work here is done.

            M Offline
            M Offline
            Michael Bookatz
            wrote on last edited by
            #5

            Finally someone noticed my brilliance! and I put it all down to knowing google!

            N 1 Reply Last reply
            0
            • M Michael Bookatz

              Finally someone noticed my brilliance! and I put it all down to knowing google!

              N Offline
              N Offline
              Nagy Vilmos
              wrote on last edited by
              #6

              hopingToCode wrote:

              I put it all down to knowing Kung Foo!

              fixed it:suss:


              Panic, Chaos, Destruction. My work here is done.

              1 Reply Last reply
              0
              • M Mninawa

                Hi Guys, Can someone help me,i need help with Regex.I want to validate a date in this format MM/YYYY,thus 02/2009, Regards Mninawa

                P Offline
                P Offline
                PauloCastilho
                wrote on last edited by
                #7

                Regex: \d{2}\/\d{4} Code:

                public static bool IsDate(string date)
                {
                return Regex.IsMatch(date, @"^(\d{2}\/\d{4})$");
                }

                M D 2 Replies Last reply
                0
                • M Mninawa

                  Hi Guys, Can someone help me,i need help with Regex.I want to validate a date in this format MM/YYYY,thus 02/2009, Regards Mninawa

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  You could always try a variation of this[^].

                  "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                  As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                  My blog | My articles | MoXAML PowerToys | Onyx

                  1 Reply Last reply
                  0
                  • P PauloCastilho

                    Regex: \d{2}\/\d{4} Code:

                    public static bool IsDate(string date)
                    {
                    return Regex.IsMatch(date, @"^(\d{2}\/\d{4})$");
                    }

                    M Offline
                    M Offline
                    Mninawa
                    wrote on last edited by
                    #9

                    Thanx Buddy you have saved my day. Mninawa

                    1 Reply Last reply
                    0
                    • P PauloCastilho

                      Regex: \d{2}\/\d{4} Code:

                      public static bool IsDate(string date)
                      {
                      return Regex.IsMatch(date, @"^(\d{2}\/\d{4})$");
                      }

                      D Offline
                      D Offline
                      deepakaitr12345
                      wrote on last edited by
                      #10

                      From my side 5/5 :thumbsup:

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups