Homework: Ruby Regular Expressions
Purpose
- Learn to use basic regular expressions in Ruby
Preparation
- Download the unit tests
This exercise may be done with a partner.
Regex
This assignment provides practice with some of the basic regular expression capabilities. You should:
- Download the unit tests, name the file
regex_practice_tester.rb
. - Create a module named
RegexPractice
in a file namedregex_practice.rb
. - Write the required methods (pay attention to hints). When you run
regex_practice_tester.rb
your output should be similar to the output below(i.e., 26 assertions, 0 failures, 0 errors).
$ ruby regex_practice_tester.rb
Run options: --seed 14369
# Running:
.......
Finished in 0.005669s, 1234.7171 run/s, 4586.0920 assertion/s.
7 runs, 26 assertions, 0 failures, 0 errors, 0 skips
Rubric
This exercise is worth 16 points.
Points | Metric |
---|---|
2 | ruby_begins_lines |
2 | get_language |
4 | is_complex – must pass all tests |
2 | what_is_cool |
2 | what_i_like |
2 | get_last_word |
2 | get_price |
For ease of grading, ensure the grader can execute your tests by entering
ruby regex_practice_tester.rb
at the command line.