Welcome! Log In Create A New Profile


Ass2 Q2

Posted by conman 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Ass2 Q2
May 19, 2010 01:59PM
With regards to the regular expressions. I am wondering if we need to build validation into it (i.e restrict the input to the correct number of days in the month) or are they just looking for the format of the date. Anyone have an idea?
avatar Re: Ass2 Q2
May 23, 2010 06:36PM
My program will accept any input and evaluate it using the regular expression. Then print a message saying weather or not it was a valid date; therefore no restriction to input.
Re: Ass2 Q2
May 25, 2010 01:51PM
I was thinking more along the lines of date validation in terms of checking the number of days in the month is correct (not validation on input itself) but more specifically a rule which I would rather not do and that is check for leap years.. I have no idea where to begin on doing a validation rule to include date validation that has leap years included in the regular expression.
Re: Ass2 Q2
June 20, 2010 01:43PM
I've got a regexp that accepts valid months[01-12] and days[01-31], but there's no correlation between the month and the day, so it accepts 2010-02-31.
It also doesn't cater for leap years.
avatar Re: Ass2 Q2
June 23, 2010 12:02PM
Can't you use QDate instead? It's QDate:: isValid() function works just like you want it to.
avatar Re: Ass2 Q2
June 23, 2010 12:09PM
There is no way that you can use QRegExp to validate a date, even when using the more advanced features like assertions (e.g. looking forward). I think the best you can do is use the QRegExp to restrict the format of the input and then validate afterwards.

Go back to the requirements specification for the question. If it is vague, say so in your assignment. If it lacks information, make an assumption and state that in your assignment too. This is a third level course, you're supposed to show you can think for yourself not just produce output like a robot. Showing your thought process can help a lot.
Re: Ass2 Q2
July 04, 2010 11:18AM
@Rob see this link http://regexlib.com/REDetails.aspx?regexp_id=166.

^((((31\/(0?[13578]|1[02]))|((29|30)\/(0?[1,3-9]|1[0-2])))\/(1[6-9]|[2-9]\d)?\d{2})|(29\/0?2\/(((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))|(0?[1-9]|1\d|2[0-8])\/((0?[1-9])|(1[0-2]))\/((1[6-9]|[2-9]\d)?\d{2})) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$

Although I would not like to inherit the responsibility of maintaining that expression as part of an application.
avatar Re: Ass2 Q2
July 04, 2010 12:07PM
Sorry, only registered users may post in this forum.

Click here to login