Hi, I just need a little help with a problem Iam doing, I think I've almost figured it out I just need some help finishing it. Ive been asked to write a regular expression to see whether a string represents a valid roman numeral. So I did that pretty much..
How would I go about testing this program, is there anything I need to add, to proceed from here?
Any help would be much appreciated,
Thanks,
Dan
You should try to look at the output of roman.inspect() or roman.to_yaml() will give you an idea of what the object that Regexp.new() has returned. That may help you to proceed.
I forgot to include that in order to test your example, you'll have to do:
numeral = "XVIII"
roman.match(numeral)
Also, you can evaluate a regexp using the =~ operator like this:
"XVIII" =~ /romanRegexp/
the results of the match are available in the global variables $1, $2, $3, ...
Have a look at the documentation (http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_stdtypes.html)