ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 27th, 2012, 10:07 AM
dlopez dlopez is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 64 dlopez User rank is Corporal (100 - 500 Reputation Level)dlopez User rank is Corporal (100 - 500 Reputation Level)dlopez User rank is Corporal (100 - 500 Reputation Level)dlopez User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 33 m 11 sec
Reputation Power: 3
MVC3 RegEx question (c#)

Hello all,

I'm attempting to validate the date and time, separately. I think I have it right, but I just want to check my work.

for the time I have:
PHP Code:
^(?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$ 

for the date I have:
PHP Code:
^(?:2?[0-9][0-9][0-9]):[0-1][0-2]:(0?[1-9]|1[0-9]|2[0-9]|3[0-1])$ 


Could anyone help verify this?

Thanks!

Reply With Quote
  #2  
Old March 27th, 2012, 12:57 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,702 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 5 h 32 m 15 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Those can be simplified.
Code:
time ^([01]?\d|2[0-3]):[0-5]\d:[0-5]\d$
date ^[12]\d\d\d:(0\d|1[012]):([012]\d|3[01])$

(\d is equivalent to [0-9])

The time one is perfect but the date one requires more validation.

Reply With Quote
  #3  
Old March 28th, 2012, 11:05 AM
dlopez dlopez is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 64 dlopez User rank is Corporal (100 - 500 Reputation Level)dlopez User rank is Corporal (100 - 500 Reputation Level)dlopez User rank is Corporal (100 - 500 Reputation Level)dlopez User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 33 m 11 sec
Reputation Power: 3
Quote:
Originally Posted by requinix
Those can be simplified.
Code:
time ^([01]?\d|2[0-3]):[0-5]\d:[0-5]\d$
date ^[12]\d\d\d:(0\d|1[012]):([012]\d|3[01])$

(\d is equivalent to [0-9])

The time one is perfect but the date one requires more validation.


PHP Code:
^[12]\d\d\d:(0\d|1[012]):([012]\d|3[01])$ 


Will this be military format, though? If not, how would I know the difference in AM or PM? I've always just used military time to calculate. also, I'm trying to get the format in YYYY-MM-DD. I'm used to MySQL style databases, but I'm switching to the .Net world and working with SQL Server 2008, now.

*** This is an MVC3 app, also. Just throwing that out there.

Reply With Quote
  #4  
Old March 28th, 2012, 01:48 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,702 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 5 h 32 m 15 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
That's the date regex.

As YYYY-MM-DD it would look like the same but with hyphens instead of colons.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > MVC3 RegEx question (c#)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap