|
|
Re: Need help with my programming homwork!
|
Posted: Jan 5, 2006 12:38 PM
|
|
Homework usually isn't answered, but I think it's been long enough.
N -> "[0-9]"
That'll give you a digit from 0 to 9 in regular expression notation.
D is any sequence of digits with at least 1 digit.
D -> "[0-9]+"
The "+" means one or more, so that's exactly what "ND | N" means.
Finally, we have digits followed by a "." and optional following digits.
N -> "[0-9]+\.[0-9]*"
That's your answer. The last digits, I used a "*" which means 0 or more. Since 0 digits is allowable, this makes it optional. The backslash is used on the "." because in regular expression notation a dot means any character. A backslash takes the following character as is.
|
|